Python beautifulsoup not grabbing full table -
I'm not sure that it is not holding the full table due to This works: but it is not: that Works without, so it may be related to mechanize
Beautiful soup import page to import from imports = 'http://www.airchina.com.cn/www/jsp/airlines_operating_data/exlshow_en .jsp 'r = request.get (page) r.encoding =' utf-8 'soup = beautiful soup (rtext) div = soup.find (' div ', class_ =' main right '). Find_all ('div') [1] for cell in table row ('TD', recursive = falls) = div.find ('table', recursive = False) in the row. Find_all ('tr', recursive = falls): print cell.text.split ()
Import import import imports BS4 Import Beautiful Soup Import Request URL = 'http: //www.airchina.com.cn/www/jsp/airlines_operating_data/exlshow_en.jsp' control_year = ['2006', '2007', '2008', '200 9 '01', '02', '03', '04', '05', '06 ',' 0 ',' 0 ' 07 ',' 08 ', '09', '10', '11', '12'] Br = Entered. Broser () r = br.open (url) b r.select_form ("exl") control_m = br.form.find_control ('month') control_y = br.form.find_control ('year') br [control_m.name] = ['06'] br [control_y.name] = ['2012'] reaction = br.submit () soup = beautiful soup (feedback, 'html.parser') #div = soup.find ('div', class_ = 'Main right') div = soup.find ('find_all' ('div') [1] for line for div table = div.find ('table', recursive = folose). Tr ', recursive = falls): in line for cell (' TD ', recursive = falls): print cell.text.stip ()
mechanize use The person only produces the bottom, even if in firebug I
tr and
td
June 2012% vs Changes vs. June 2011 % Change versus May 2012 cumulative June 2012% cumulative change
html.parser you are using.
Comments
Post a Comment