开心的衡衡
2019-08-01 05:19
import urllib.request
req = request.Requst("http://www.baidu.com")
req.add_header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36")
resp = request.urlopen(req)
print(resp.read().decode("utf-8"))
报错
Traceback (most recent call last):
File "C:\a spider enviroment\study file\try.py", line 3, in <module>
req = request.Requst("http://www.baidu.com")
NameError: name 'request' is not defined
[Finished in 0.5s with exit code 1]
[shell_cmd: python -u "C:\a spider enviroment\study file\try.py"]
[dir: C:\a spider enviroment\study file]
[path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\BlueStone\Anaconda3;C:\Users\BlueStone\Anaconda3\Library\mingw-w64\bin;C:\Users\BlueStone\Anaconda3\Library\usr\bin;C:\Users\BlueStone\Anaconda3\Library\bin;C:\Users\BlueStone\Anaconda3\Scripts;C:\Users\BlueStone\AppData\Local\Microsoft\WindowsApps]
request = urllib.request.Request(url) 改成这样试试
python遇见数据采集
59669 学习 · 200 问题
相似问题