From 7b1db4ed1cbb46c4033829581426bdf875fcda6b Mon Sep 17 00:00:00 2001 From: lfk <2668413029@qq.com> Date: Thu, 25 Apr 2024 21:50:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86url=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/SpyderController.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/SpyderController.py b/controller/SpyderController.py index 2a1d2ee..7605ec5 100644 --- a/controller/SpyderController.py +++ b/controller/SpyderController.py @@ -27,14 +27,14 @@ class SpyderController: threadCount = videoCount if videoCount > 100: videoCount = 100 - url = "https://api.bilibili.com/x/web-interface/ranking/v2?" + json_url = "https://api.bilibili.com/x/web-interface/ranking/v2?" headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0' } #f = open("file_3.csv", "a", encoding="UTF-8", newline="") #csv_writer = csv.writer(f) - rank_text = requests.get(url=url, headers=headers).text + rank_text = requests.get(url=json_url, headers=headers).text # 将含有"万"的数据转换为数字 def crawl_data(start_index, end_index): def convert_to_number(lst): @@ -63,8 +63,8 @@ class SpyderController: bvId = [str(parsed_data['data']['list'][i]['bvid'])] topNo = [str(i+1)] - video_url = "https://www.bilibili.com/video/av" + aid + "/?" - video_text = requests.get(url=video_url, headers=headers).text + url = "https://www.bilibili.com/video/av" + aid + "/?" + video_text = requests.get(url=url, headers=headers).text tree = etree.HTML(video_text) #print(video_text) title = tree.xpath('//div[@class="video-info-title-inner"]//text()')