要回答您的问题:
import urlliblink = "http://www.somesite.com/details.pl?urn=2344"f = urllib.urlopen(link)myfile = f.read()print(myfile)
您需要
read(),而不是
readline()
编辑(2018-06-25):自Python
3起,旧版
urllib.urlopen()被替换为
urllib.request.urlopen()(有关详细信息,请参阅https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen中的注释)
。
或者,只需在此处获取此库:http :
//docs.python-requests.org/en/latest/并认真使用它即可:)
import requestslink = "http://www.somesite.com/details.pl?urn=2344"f = requests.get(link)print(f.text)



