Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nghuyong committed Nov 25, 2022
1 parent 96f03eb commit f4c2cba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions weibospider/spiders/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ def start_requests(self):
start_time = "2022-10-01-0" # 格式为 年-月-日-小时, 2022-10-01-0 表示2022年10月1日0时
end_time = "2022-10-07-23" # 格式为 年-月-日-小时, 2022-10-07-23 表示2022年10月7日23时
is_search_with_specific_time_scope = True # 是否在指定的时间区间进行推文搜索
is_sort_by_hot = True # 是否按照热度排序,默认按照时间排序
for keyword in keywords:
if is_search_with_specific_time_scope:
url = f"https://s.weibo.com/weibo?q={keyword}&timescope=custom%3A{start_time}%3A{end_time}&page=1"
else:
url = f"https://s.weibo.com/weibo?q={keyword}&page=1"
if is_sort_by_hot:
url += "&xsort=hot"
yield Request(url, callback=self.parse, meta={'keyword': keyword})

def parse(self, response, **kwargs):
Expand Down

0 comments on commit f4c2cba

Please sign in to comment.