为了从列表url打印出HTML,我使用python编写了以下代码:
import mechanize, fileinput
urls = open('F:\Python\url_list.txt')
content = [x.strip() for x in urls.readlines()]
print content
browser = mechanize.Browser()
browser.open("https://login.asp")
browser.select_form(nr=0)
browser['desc'] = "xxxxx"
browser['password'] = "xxxxx"
response = browser.submit()
logincheck = response.read()
print logincheck
# now logged into site, loop through the list of urls read in from the text file and print the html for each one:
for s in content:
releasenote = browser.urlopen(s)
# error here, should be releasenote = browser.open(s)
print releasenote.geturl()
print releasenote.info()
print releasenote.read()
但是,我在python shell中得到以下错误:
^{pr2}$我做错什么了?干杯!在
它是
mechanize.urlopen(s)
或者就像你说的
browser.open(s)
。在相关问题 更多 >
编程相关推荐