Created
January 26, 2014 19:15
-
-
Save richardhsu/8637724 to your computer and use it in GitHub Desktop.
Request Page from SSA for Names By State with Python 3 and urllib.
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/env python3 | |
import urllib.request | |
import urllib.parse | |
url = 'http://www.ssa.gov/cgi-bin/namesbystate.cgi' | |
post_data = { | |
'state': 'IL', | |
'year': '2012' | |
} | |
post_encode = urllib.parse.urlencode(post_data) | |
post_encode = post_encode.encode('UTF-8') | |
request = urllib.request.Request(url, post_encode) | |
response = urllib.request.urlopen(request).read().decode('UTF-8', 'ignore') | |
# HTML Data now in Response | |
print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment