Fix Python – How to get everything after last slash in a URL?

How can I extract whatever follows the last slash in a URL in Python? For example, these URLs should return the following:
URL: http://www.test.com/TEST1
returns: TEST1

URL: http://www.test.com/page/TEST2
returns: TEST2

URL: http://www.test.com/page/page/12345
returns: 12345

I’ve tried urlparse, but that gives me the full path filename, such as….

Fix Python – Extracting an attribute value with beautifulsoup

I am trying to extract the content of a single “value” attribute in a specific “input” tag on a webpage. I use the following code:
import urllib
f = urllib.urlopen(“http://58.68.130.147”)
s = f.read()
f.close()

from BeautifulSoup import BeautifulStoneSoup
soup = BeautifulStoneSoup(s)

inputTag = soup.findAll(attrs={“name” : “stainfo”})

output = ….

Fix Python – Python/Json:Expecting property name enclosed in double quotes

I’ve been trying to figure out a good way to load JSON objects in Python.
I send this json data:
{‘http://example.org/about’: {‘http://purl.org/dc/terms/title’: [{‘type’: ‘literal’, ‘value’: “Anna’s Homepage”}]}}

to the backend where it will be received as a string then I used json.loads(data) to parse it.
But each time I got the same exception :….

Fix Python – How to parse data in JSON format

My project is currently receiving a JSON message in python which I need to get bits of information out of. For the purposes of this, let’s set it to some simple JSON in a string:
jsonStr = ‘{“one” : “1”, “two” : “2”, “three” : “3”}’

So far I’ve been generating JSON requests using a list and then json.dumps, but to do the opposite of this I think ….