From 0184dec59cc3ff0bdfb42b287456fa87dff7227b Mon Sep 17 00:00:00 2001 From: ngfchl Date: Sat, 31 Dec 2022 14:46:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=A6=E6=A0=A1=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_site/UtilityTool.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pt_site/UtilityTool.py b/pt_site/UtilityTool.py index ed9ddd1..1fb224b 100644 --- a/pt_site/UtilityTool.py +++ b/pt_site/UtilityTool.py @@ -1565,6 +1565,20 @@ class PtSpider: ]: logger.info(site.url) details_html = etree.HTML(converter.convert(user_detail_res.text)) + if 'btschool' in site.url: + text = details_html.xpath('//script/text()') + logger.info('学校:{}'.format(text)) + if len(text) > 0: + try: + location = self.parse_school_location(text) + logger.info('学校重定向链接:{}'.format(location)) + if '__SAKURA' in location: + res = self.send_request(my_site=my_site, url=site.url + location.lstrip('/'), delay=25) + details_html = etree.HTML(res.text) + # logger.info(res.content) + except Exception as e: + logger.info('BT学校获取做种信息有误!') + pass seeding_html = details_html elif 'hdchina.org' in site.url: details_html = etree.HTML(converter.convert(user_detail_res.text)) @@ -1608,21 +1622,6 @@ class PtSpider: # seeding_html = details_html.xpath('//div[@id="ka2"]/table')[0] else: details_html = etree.HTML(converter.convert(user_detail_res.text)) - - if 'btschool' in site.url: - text = details_html.xpath('//script/text()') - logger.info('学校:{}'.format(text)) - if len(text) > 0: - try: - location = self.parse_school_location(text) - logger.info('学校重定向链接:{}'.format(location)) - if '__SAKURA' in location: - res = self.send_request(my_site=my_site, url=site.url + location.lstrip('/'), delay=25) - details_html = etree.HTML(res.text) - # logger.info(res.content) - except Exception as e: - logger.info('BT学校获取做种信息有误!') - pass if 'wintersakura' in site.url: # 单独发送请求,解决冬樱签到问题 seeding_detail_res = requests.get(url=seeding_detail_url, verify=False,