批量获取 Btsow 网站搜索到的磁力链接

2023-12-06 02:12

本文主要是介绍批量获取 Btsow 网站搜索到的磁力链接,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

BTSOW 是个不错的种子或磁力链接搜索网站,本脚本可以按需要批量抓取 磁力链接(老司机必备)
功能:
1.获取最新地址(网站经常失联)
2.最多50页内容(网站限制)
3.结果生成CSV文件(可用excel打开后进一步筛选文件尺寸,剔除小文件) 

 

代码:

from bs4 import BeautifulSoup
import requests
import re
import datetime
import pyperclip
import time
import subprocess
from time import sleep
import random
import csv
from urllib.parse import quotex = datetime.datetime.now()
print('任务开始于:'+str(x)+'\n')
today=x.strftime("%Y")+'-'+x.strftime("%m")+'-'+x.strftime("%d")
#print(today)s = requests.Session()Headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.50'}tellme_url='https://tellme.pw/bts'reponse = s.get(url=tellme_url,headers=Headers)
# print(reponse.text)
soup= BeautifulSoup(reponse.text,'lxml')
# print(soup.prettify())
h2_tag = soup.find('h2')
new_url=h2_tag.a['href']
print('最新网址:\t'+new_url)gjc=input("关 键 词:\t")seach_url = new_url+'/search/'+quote(gjc)
# print(seach_url)
reponse=s.get(url=seach_url,headers=Headers)
# print(reponse.text)mag=[]
title=[]
sizenum=[]
date=[]# pagination pagination-lg
# /html/body/div[2]/div[7]/ul/li[1]
# body > div.container > div:nth-child(9) > ul > li.hidden-xs.active
maxpage=0# maxpage<=50
for p in range(1,52):html=s.get(seach_url+'/page/'+str(p),headers=Headers)allhtml=html.textif p==1:print('正在尝试:\t'+seach_url+'/page/'+str(p))soup= BeautifulSoup(allhtml,'lxml')data_list=soup.find_all("a",{"href":re.compile("\/\/btsow\.*?"),"title":re.compile('.*?')})for i in data_list:mag.append('magnet:?xt=urn:btih:'+i.get('href')[-40:])title.append(i.get('title'))soup=BeautifulSoup(str(i),"lxml")size=soup.find("div",{"class":re.compile('.*?size')})info=size.get_text().split(" / ")sizen=info[0][5:-2]sizedw=info[0][-2:]if sizedw=="TB":sizenum.append(float(sizen)*1024**2)elif sizedw=="GB":sizenum.append(float(sizen)*1024)elif sizedw=="MB":sizenum.append(float(sizen))elif sizedw=="KB":sizenum.append(float(sizen)/1024)else:sizenum.append(0)date.append(info[1][13:])if p > 1:soup=BeautifulSoup(allhtml,'lxml')page=soup.find("ul",{"class":'pagination pagination-lg'})# if page.txt.find("Next")if page == None:maxpage=p-1breakelse:print('正在尝试:\t'+seach_url+'/page/'+str(p))soup= BeautifulSoup(allhtml,'lxml')data_list=soup.find_all("a",{"href":re.compile("\/\/btsow\.*?"),"title":re.compile('.*?')})for i in data_list:mag.append('magnet:?xt=urn:btih:'+i.get('href')[-40:])title.append(i.get('title'))soup=BeautifulSoup(str(i),"lxml")size=soup.find("div",{"class":re.compile('.*?size')})info=size.get_text().split(" / ")sizen=info[0][5:-2]sizedw=info[0][-2:]if sizedw=="TB":sizenum.append(float(sizen)*1024**2)elif sizedw=="GB":sizenum.append(float(sizen)*1024)elif sizedw=="MB":sizenum.append(float(sizen))elif sizedw=="KB":sizenum.append(float(sizen)/1024)else:sizenum.append(0)date.append(info[1][13:])sleep(random.randint(1,10))# soup= BeautifulSoup(allhtml,'lxml')
# # print(soup.text)
# # print(soup.get_text)
# # data_list=soup.find("div",{'class':"data-list"})
# # print(data_list)
# # print(type(data_list))
# # soup= BeautifulSoup(data_list.text,"lxml")
# data_list=soup.find_all("a",{"href":re.compile("\/\/btsow\.*?"),"title":re.compile('.*?')})# for i in data_list:
#     mag.append('magnet:?xt=urn:btih:'+i.get('href')[-40:])
#     title.append(i.get('title'))
#     soup=BeautifulSoup(str(i),"lxml")
#     size=soup.find("div",{"class":re.compile('.*?size')})
#     info=size.get_text().split(" / ")
#     sizen=info[0][5:-2]
#     sizedw=info[0][-2:]
#     if sizedw=="TB":
#         sizenum.append(float(sizen)*1024**2)
#     elif sizedw=="GB":
#         sizenum.append(float(sizen)*1024)
#     elif sizedw=="MB":
#         sizenum.append(float(sizen))
#     elif sizedw=="KB":
#         sizenum.append(float(sizen)/1024)
#     else:
#         sizenum.append(0)#     date.append(info[1][13:])
# sleep(random.randint(1,10))# print("%s\n%s\n%s\nMB\n%s\n" %(mag,title,sizenum,date))
# maxindex=sizenum.index(max(sizenum))
# print('magnet:?xt=urn:btih:'+mag[maxindex] +'  '+title[maxindex])# print(len(mag))
# print(len(title))
# print(len(sizenum))if len(mag)==0:print('未找到任何资源')if len(mag)>0:print('最大页数:\t',maxpage)print('链接数量:\t',len(mag))print('详细内容:')for i in range(len(mag)):print(mag[i]+'\t'+str(sizenum[i])+'\t\t'+title[i])
if maxpage>1:rows = zip(title, mag, sizenum ,date)# print(len(rows))with open(gjc+'.csv', mode='w', newline='',encoding='utf-8-sig') as file:writer = csv.writer(file)writer.writerow(['种子名','磁力链接', '文件大小(单位:MB)', '日期'])for row in rows:writer.writerow(row)print('写入文件:\t'+gjc+'.csv')

这篇关于批量获取 Btsow 网站搜索到的磁力链接的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/460007

相关文章

shell脚本批量导出redis key-value方式

《shell脚本批量导出rediskey-value方式》为避免keys全量扫描导致Redis卡顿,可先通过dump.rdb备份文件在本地恢复,再使用scan命令渐进导出key-value,通过CN... 目录1 背景2 详细步骤2.1 本地docker启动Redis2.2 shell批量导出脚本3 附录总

批量导入txt数据到的redis过程

《批量导入txt数据到的redis过程》用户通过将Redis命令逐行写入txt文件,利用管道模式运行客户端,成功执行批量删除以Product*匹配的Key操作,提高了数据清理效率... 目录批量导入txt数据到Redisjs把redis命令按一条 一行写到txt中管道命令运行redis客户端成功了批量删除k

Python获取浏览器Cookies的四种方式小结

《Python获取浏览器Cookies的四种方式小结》在进行Web应用程序测试和开发时,获取浏览器Cookies是一项重要任务,本文我们介绍四种用Python获取浏览器Cookies的方式,具有一定的... 目录什么是 Cookie?1.使用Selenium库获取浏览器Cookies2.使用浏览器开发者工具

Java获取当前时间String类型和Date类型方式

《Java获取当前时间String类型和Date类型方式》:本文主要介绍Java获取当前时间String类型和Date类型方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录Java获取当前时间String和Date类型String类型和Date类型输出结果总结Java获取

Python实现批量提取BLF文件时间戳

《Python实现批量提取BLF文件时间戳》BLF(BinaryLoggingFormat)作为Vector公司推出的CAN总线数据记录格式,被广泛用于存储车辆通信数据,本文将使用Python轻松提取... 目录一、为什么需要批量处理 BLF 文件二、核心代码解析:从文件遍历到数据导出1. 环境准备与依赖库

C#监听txt文档获取新数据方式

《C#监听txt文档获取新数据方式》文章介绍通过监听txt文件获取最新数据,并实现开机自启动、禁用窗口关闭按钮、阻止Ctrl+C中断及防止程序退出等功能,代码整合于主函数中,供参考学习... 目录前言一、监听txt文档增加数据二、其他功能1. 设置开机自启动2. 禁止控制台窗口关闭按钮3. 阻止Ctrl +

linux批量替换文件内容的实现方式

《linux批量替换文件内容的实现方式》本文总结了Linux中批量替换文件内容的几种方法,包括使用sed替换文件夹内所有文件、单个文件内容及逐行字符串,强调使用反引号和绝对路径,并分享个人经验供参考... 目录一、linux批量替换文件内容 二、替换文件内所有匹配的字符串 三、替换每一行中全部str1为st

基于Python开发一个图像水印批量添加工具

《基于Python开发一个图像水印批量添加工具》在当今数字化内容爆炸式增长的时代,图像版权保护已成为创作者和企业的核心需求,本方案将详细介绍一个基于PythonPIL库的工业级图像水印解决方案,有需要... 目录一、系统架构设计1.1 整体处理流程1.2 类结构设计(扩展版本)二、核心算法深入解析2.1 自

Python自动化批量重命名与整理文件系统

《Python自动化批量重命名与整理文件系统》这篇文章主要为大家详细介绍了如何使用Python实现一个强大的文件批量重命名与整理工具,帮助开发者自动化这一繁琐过程,有需要的小伙伴可以了解下... 目录简介环境准备项目功能概述代码详细解析1. 导入必要的库2. 配置参数设置3. 创建日志系统4. 安全文件名处

SpringBoot中六种批量更新Mysql的方式效率对比分析

《SpringBoot中六种批量更新Mysql的方式效率对比分析》文章比较了MySQL大数据量批量更新的多种方法,指出REPLACEINTO和ONDUPLICATEKEY效率最高但存在数据风险,MyB... 目录效率比较测试结构数据库初始化测试数据批量修改方案第一种 for第二种 case when第三种