From d9f4cfa44a33295f6db5ae84c62b68ebe8ba013d Mon Sep 17 00:00:00 2001 From: hillerliao Date: Tue, 10 Aug 2021 21:47:30 +0800 Subject: [PATCH] add headers to mp gh request --- rsshub/spiders/mp/gh.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rsshub/spiders/mp/gh.py b/rsshub/spiders/mp/gh.py index 04aecf7..b6811cf 100644 --- a/rsshub/spiders/mp/gh.py +++ b/rsshub/spiders/mp/gh.py @@ -1,4 +1,5 @@ from rsshub.utils import fetch +from rsshub.utils import DEFAULT_HEADERS domain = 'https://weixin.sogou.com' @@ -16,8 +17,8 @@ def parse(post): def ctx(gh=''): global url - url = f"{domain}/weixin?query={gh}" - tree = fetch(url) + url = f"{domain}/weixin?type=1&s_from=input&query={gh}&ie=utf8&_sug_=n&_sug_type_=&w=01019900&sut=1554&sst0=1628603087755&lkt=0%2C0%2C0" + tree = fetch(url=url, headers=DEFAULT_HEADERS) global dd_num dd_num = len( tree.css('dd') ) posts = [ tree.css('dd')[-1] ]