zipc = "47408"
url = "http://watchdog.net/us/?zip="
conn = u.urlopen(url+zipc)
content = conn.readlines()
for line in content:
line = line.decode("utf-8")
So I am working on a CGI/Python project that requires input of a zipcode to then find the name of a certain politician. Right now I am trying to find a way to extract that name from the code.
I am currently inputing the zipcode of 47408 into the watchdog webpage. This access' Baron Hill's Distrcict. In the code I need to extract this: <a href="/p/NAME"> where NAME should equal the name of the politician from the given zipcode, or in this case baron_hill.
My question is how do I extract the 'baron_hill' or NAME part from the page source?
I was told to use the "find" method, but I can not get it to work quite how I'd like.
Above is the small piece of code I've been using to give you all a general idea of what I'm doing.
I am working with Python3.
Thanks for any input!