Skip to content

Instantly share code, notes, and snippets.

@ahmednuaman
Created October 3, 2014 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmednuaman/5e1fbc0a9f95a5f698c5 to your computer and use it in GitHub Desktop.
Save ahmednuaman/5e1fbc0a9f95a5f698c5 to your computer and use it in GitHub Desktop.
A simple example of how to parse a page with python
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