import urllib.request
url = 'http://www.fishc.com'
urllib.request.install_opener(url)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print(html[0:299])
这么写行么?
目前还是报错>>>
================== RESTART: C:/Users/user/Desktop/20210517b.py =================
Traceback (most recent call last):
File "C:/Users/user/Desktop/20210517b.py", line 7, in <module>
response = urllib.request.urlopen(url)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
AttributeError: 'str' object has no attribute 'open'
>>>
|