Created
March 13, 2014 15:22
-
-
Save tommeagher/9530488 to your computer and use it in GitHub Desktop.
Helping troubleshoot a scrape for PythonJournos
This file contains 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 | |
import csv | |
from BeautifulSoup import BeautifulSoup | |
url = "https://www.uif.uillinois.edu/simpledetail.aspx?id=91" | |
html = urllib2.urlopen(url).read() | |
soup = BeautifulSoup(html) | |
names = soup.find('ul', {'class':'people'}) | |
names_table = names.findAll('li') | |
outfile = open('out.txt', 'a') | |
for name in names_table: | |
name = name.find('strong').text.strip() | |
if name: | |
outfile.write(name+'\n') | |
outfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beautiful. Works perfectly.