table = soup.find("table", { "class" : "infobox ww_ib ww_ib_1" }) is not working

I'm trying to parse the table given at this location: "http://en.wikipedia.org/wiki/Quartz" The property table is identified as the class = infobox ww_ib ww_ib_1. I am expecting to obtain the values given in the table such as: 'Category, Oxide, Chemical formula etc..." However, the table returns a None type. Could someone please help me?

from bs4 import BeautifulSoup
import requests
wiki = "http://en.wikipedia.org/wiki/Quartz"
header = {'User-Agent': 'Mozilla/5.0'}
req = requests.get(wiki,headers=header)
soup = BeautifulSoup(req.content)
table = soup.find("table", { "class" : "infobox ww_ib ww_ib_1" })
print (table)

Please do let me know if you know of better ways to scrape wikipedia!

web-scrapingbeautifulsoupwikipediawikipedia-api

Answers

answered 4 months ago vineeth venugopal #1

I was able to figure out what the problem was. The class of the table is just 'infobox' and not 'infobox ww_ib ww_ib_1"

comments powered by Disqus