我已经使用'pip install requests'
安装了请求,但什么也得不到。
我遵循基本tutorial中给出的示例,并在此code
上继续获取此error
from bs4 import BeautifulSoup
page = requests.get('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.29563999999999#.Xq3cLZl7lPY')
soup = BeautifulSoup(page.content, 'html-parser')
print(soup)
和error
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-90e58007c1ee> in <module>
1 from bs4 import BeautifulSoup
----> 2 page = requests.get('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.29563999999999#.Xq3cLZl7lPY')
3 soup = BeautifulSoup(page.content, 'html-parser')
4 print(soup)
NameError: name 'requests' is not defined
发布于 2020-05-03 05:41:13
我认为,你需要import requests
。你可以试试:
from bs4 import BeautifulSoup
import requests
page = requests.get('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.29563999999999#.Xq3cLZl7lPY')
soup = BeautifulSoup(page.text, 'lxml')
print(soup)
https://stackoverflow.com/questions/61566552
复制相似问题