Monday, 26 August 2013

Not able to get all the links properly

Not able to get all the links properly

I am new to python, and have little confusion over the code.
In the below code i am trying to get all the links of one table, this is
giving me all the links, the code is this:
>>> import mechanize
>>> from BeautifulSoup import BeautifulSoup
>>> i=0
url = "http://www.miamidade.gov/water/bill_app/bill_expired.asp"
br = mechanize.Browser()
br.open(url)
br.select_form(name="frm")
br["AcctId"] = '8428995632'
br.submit()
for link in br.links(url_regex="ID="):
billurl = "http://www.miamidade.gov/water/bill_app/"+link.url
billdata = br.open(billurl)
html = billdata.read()
soup1 = BeautifulSoup(html)
print link
now when i am adding one more parameter to get print of the same page, i
am not getting all the links which were printed previously and data which
i want to print for all the links page, below is the code, his is the
extra line i have added
print soup1('font')[0].text[11:]

No comments:

Post a Comment