1

I am trying to fetch data from webpage which contains table and then compare values in table with other table values. Can I convert webpage into json data or dictionary in python? e.g. I have url www.yahoo.com how can I covert html data into json? I tried

response = urllib2.urlopen(url)

data = str(response.read())

I get html output. If I try json.loads(data) I get error raise ValueError("No JSON object could be decoded") Is there way to pull data from table which is displayed on webpage

user2661518
  • 2,677
  • 9
  • 42
  • 79

1 Answers1

0

Use beautifulsoup (http://www.crummy.com/software/BeautifulSoup/bs4/doc/) to extract the table then convert it. Try Convert a HTML Table to JSON; it shows how to use beautifulsoup to grab the table and convert it into JSON.

Community
  • 1
  • 1
zebralove79
  • 100
  • 7