Created
December 6, 2013 16:10
-
-
Save davemenninger/7827320 to your computer and use it in GitHub Desktop.
for a given address, find what cincinnati public school you would be assigned
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
#!/usr/bin/python | |
import urllib | |
import urllib2 | |
from bs4 import BeautifulSoup | |
url = "http://slg.cps-k12.org/slg/school-lookup.asp" | |
#url = "http://slg.cps-k12.org/slg/school-lookup-nextyear.asp" | |
values = { | |
'CurrentStep':'ShowSchools', | |
'txtHouseNumber':'800', | |
'txtStreetName':'Vine St' | |
} | |
data = urllib.urlencode(values) | |
req = urllib2.Request(url, data) | |
response = urllib2.urlopen(req) | |
the_page = response.read() | |
soup = BeautifulSoup(the_page) | |
table = soup.find("table", {"border":"1"}) | |
rows = table.findAll('tr') | |
for tr in rows: | |
cols = tr.findAll('td') | |
for td in cols: | |
text = td.get_text() | |
print text+"|", | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment