我已经导入了bs4
from bs4 import BeautifulSoup as bs
。下面是我在代码中初始化beautiful soup的部分:
def save_sp500_tickers():
resp = requests.get('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')
soup = bs.BeautifulSoup(resp.text)
通过bash运行脚本时,出现以下错误:
16:27 ~ $ python2.7 toptickerbot.py
Traceback (most recent call last):
File "toptickerbot.py", line 332, in <module>
result()
File "toptickerbot.py", line 209, in result
data = scandata(30000000, 200000000, -0.99, 0.99, 0, 25)
File "toptickerbot.py", line 149, in scandata
tickers = save_sp500_tickers()
File "toptickerbot.py", line 26, in save_sp500_tickers
soup = bs.BeautifulSoup(resp.text)
AttributeError: type object 'BeautifulSoup' has no attribute 'BeautifulSoup'
不确定属性错误指的是什么。此外,当我在jupyter笔记本中运行代码时,它工作正常
如果删除
as bs
部分,代码将等效于:错误消息说
BeautifulSoup
没有属性BeautifulSoup
你是说这个吗
或者可能:
相关问题 更多 >
编程相关推荐