Created
October 3, 2014 14:50
-
-
Save ahmednuaman/5e1fbc0a9f95a5f698c5 to your computer and use it in GitHub Desktop.
A simple example of how to parse a page with python
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
import urllib2 | |
from bs4 import BeautifulSoup | |
page = urllib2.urlopen('http://www.bbc.co.uk/sport/football/tables') | |
soup = BeautifulSoup(page) | |
rows = soup.find_all('tr') | |
for row in rows: | |
team = row.find('td', class_='team-name') | |
if team: | |
print(team.get_text()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment