import urllib
def getUrl():
url = 'https://www.google.ie/trends/fetchComponent?hl=en-AU&q=boston%20celtics&date=now%201-d&cmpt=q&tz=Etc%2FGMT-1&tz=Etc%2FGMT-1&content=1&cid=RISING_ENTITIES_0_0&cat=0-20'
headers = {}
headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
req = urllib.request.Request(url, headers = headers)
resp = urllib.request.urlopen(req)
respData = resp.read().decode('utf-8')
print(respData)
print('......................................................')
timeframe = {'day':'d','week':'w'}
team=['boston celtics','Houston Rockets','Cleveland Cavaliers','Golden State Warriors']
for i in team:
getUrl(i,timeframe['day'])
我尝试抓取谷歌(https://www.google.ie/trends/fetchComponent?hl=en-AU&q=boston%20celtics&date=now%201-d&cmpt=q&tz=Etc%2FGMT-1&tz=Etc%2FGMT-1&content=1&cid=RISING_ENTITIES_0_0&cat=0-20)的数据,经过几次尝试,我得到了 '你已达到配额限制。请稍后再试' 有没有办法解决这个问题?
答案 0 :(得分:0)
登录然后抓取数据,它是wordks.reference:https://github.com/GeneralMills/pytrends/blob/master/pytrends/pyGTrends.py。 _connect and_init_显示如何在google登录。