当前位置:网站首页>Quick access to video links at station B

Quick access to video links at station B

2022-07-06 21:19:00 Listen to my call, rookie evolution


from lxml import etree
import time
import json
import requests
import csv
import random
import os
from fake_useragent import UserAgent
headers={
    
            'User-Agent':UserAgent().random
        }

for i in range(1,35):
    url='https://api.bilibili.com/x/web-interface/search/type?__refresh__=true&_extra=&context=&page={}&page_size=42&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&keyword=%E8%8E%8E%E5%A3%AB%E6%AF%94%E4%BA%9A%E6%88%8F%E5%89%A7%E8%A1%A8%E6%BC%94&category_id=&search_type=video&dynamic_offset=72&preload=true&com2co=true'.format(i)
    response=requests.get(url=url,headers=headers)
    data=response.json()
    
    cards=data['data']['result']
    print(i)
    for card in cards:
        li=[]
        link=card["arcurl"]# score 
        times=card["duration"]# Movie title 
        description=card["title"]#url
        li.append(link)
        li.append(times)
        li.append(description)
        
        print(li)
    
        with open('biliok.csv', 'a', newline='', encoding='utf-8-sig') as fp:
                writer = csv.writer(fp)
                writer.writerow(li)
    
    time.sleep(float(format(random.uniform(0,3), '.2f')))
        
    
    
    
    
    
    
    
    
    
        
        

原网站

版权声明
本文为[Listen to my call, rookie evolution]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061256467109.html