longxiaofei / spider-BaiduIndex

data sdk for baidu Index
MIT License
748 stars 230 forks source link

网页上能正常获取,但是qdata上总是提示【该账号请求过于频繁, 请降低请求频率】 #64

Closed Wilson1823 closed 2 years ago

Wilson1823 commented 2 years ago

如题

longxiaofei commented 2 years ago

每请求一组关键词,sleep一段时间?,比如(以下代码未实际运行)

import time

from qdata.baidu_index import get_search_index
from qdata.baidu_index.common import split_keywords

keywords_list = [['张艺兴', '汪峰'], ['百度'], ['疫情', '杭州'], ['北京', '疫情'], ['猫粮'], ['流浪猫']]
cookies = """xxx"""

for keywords in split_keywords(keywords_list):
  for index in get_feed_index(
      keywords_list=keywords,
      start_date='2018-01-01',
      end_date='2019-05-01',
      cookies=cookies
  ):
      print(index)
      time.sleep(15)
longxiaofei commented 2 years ago

更正

import time

from qdata.baidu_index import get_search_index
from qdata.baidu_index.common import split_keywords

keywords_list = [['张艺兴', '汪峰'], ['百度'], ['疫情', '杭州'], ['北京', '疫情'], ['猫粮'], ['流浪猫']]
cookies = """xxx"""

for keywords in split_keywords(keywords_list):
    for index in get_search_index(
        keywords_list=keywords,
        start_date='2018-01-01',
        end_date='2019-05-01',
        cookies=cookies
    ):
        print(index)
    time.sleep(15)