I am trying to find a good way to return a value in a url page.
I want that everytime “span class=” button” is listed I can grab the next line
"span class=" button" 0.87
I want to get 0.87
I am trying:
import urllib
url = 'http://test.com'
sock = urllib.urlopen(url)
content = sock.read().splitlines()
sock.close()
for i in content:
i = i.strip()
This is where I get stuck, how do I get the next line?
If this is HTML you could use an html parser like BeautifulSoup
this uses
nextSiblingwhich looks like it has been changed tonext_siblingin the most recent version of beautiful soup?Python has a built in HTMLParser
if your data is
you could create a class like in the example