Created
August 19, 2013 06:04
-
-
Save staticor/6266107 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rom BeautifulSoup import BeautifulSoup | |
| pageSource='''...omitted for brevity...''' | |
| soup = BeautifulSoup(pageSource) | |
| alltables = soup.findAll( "table", {"border":"2", "width":"100%"} ) | |
| results=[] | |
| for table in alltables: | |
| rows = table.findAll('tr') | |
| lines=[] | |
| for tr in rows: | |
| cols = tr.findAll('td') | |
| for td in cols: | |
| text=td.renderContents().strip('\n') | |
| lines.append(text) | |
| text_table='\n'.join(lines) | |
| if 'Website' in text_table: | |
| results.append(text_table) | |
| print "Number of tables found : " , len(results) | |
| for result in results: | |
| print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment