"Attribute Error" 在 python 上使用 pytrends 库
"Attribute Error" using pytrends library on python
我正在尝试 运行 使用 pytrends 库的脚本来抓取 Google 趋势。
import pytrends
kw_list = ["covid"]
pytrends.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
gt_o3_ytd1 = pytrends.interest_over_time()
我收到以下错误消息:
AttributeError Traceback (most recent call last)
<ipython-input-4-e6a3a9855c66> in <module>
2
3 kw_list = ["covid"]
----> 4 pytrends.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
5 gt_o3_ytd1 = pytrends.interest_over_time()
AttributeError: module 'pytrends' has no attribute 'build_payload'
尝试
mytrend = pytrends.TrendReq()
mytrend.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
gt_o3_ytd1 = pytrends.interest_over_time()
# import the TrendReq method from the pytrends request module
from pytrends.request import TrendReq
# execute the TrendReq method by passing the host language (hl) and timezone (tz) parameters
pytrends = TrendReq(hl='en-US', tz=360)
kw_list = ["covid"]
pytrends.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
gt_o3_ytd1 = pytrends.interest_over_time()
gt_o3_ytd1
我正在尝试 运行 使用 pytrends 库的脚本来抓取 Google 趋势。
import pytrends
kw_list = ["covid"]
pytrends.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
gt_o3_ytd1 = pytrends.interest_over_time()
我收到以下错误消息:
AttributeError Traceback (most recent call last)
<ipython-input-4-e6a3a9855c66> in <module>
2
3 kw_list = ["covid"]
----> 4 pytrends.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
5 gt_o3_ytd1 = pytrends.interest_over_time()
AttributeError: module 'pytrends' has no attribute 'build_payload'
尝试
mytrend = pytrends.TrendReq()
mytrend.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
gt_o3_ytd1 = pytrends.interest_over_time()
# import the TrendReq method from the pytrends request module
from pytrends.request import TrendReq
# execute the TrendReq method by passing the host language (hl) and timezone (tz) parameters
pytrends = TrendReq(hl='en-US', tz=360)
kw_list = ["covid"]
pytrends.build_payload(kw_list, cat=0, timeframe='2021-02-01 2021-07-09', geo='BR', gprop='')
gt_o3_ytd1 = pytrends.interest_over_time()
gt_o3_ytd1