Python beautifulsoup not grabbing full table -


I'm not sure that it is not holding the full table due to mechanize

This works: 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 ()

but it is not:

  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 ()   

that 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    

Works without, so it may be related to html.parser you are using. Import BS 4 from Import Import Beauti fulSoup URL = ('http://www.airchina.com.cn/www/jsp/airlines_operating_data/' 'exlshow_en.jsp') control_year = ['2006', '2007', '2008', '200', '2010', '2011', '2012', '2013', '2014'] Control_ms = ['01', '02', ' 03 ',' 04 ',' 05 ',' 06 ',' 07 '' 08 ', '09', '10', '11', '12'] br = Instrumentation. Brasar () r = br.open (url) br.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 (reaction) div = soup.fund ('div', class_ = 'mainRight'). Find_all ('div') [1] table = div.find ('table', recursive = false) for line in table.find_all ('TR', recursive = Folce): cell in row ('TD', recursive = Falls): Print cell.text .Lit ()

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -