1 Star 1 Fork 0

Harvey520 / torrentkittySearch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
torrentkitty.py 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
Harvey 提交于 2020-05-13 17:30 . 更新脚本
# coding=utf-8
import sys
import lxml
import cfscrape
from bs4 import BeautifulSoup
'''
中国内使用,需要翻墙(必须是 shadowrocks 全局模式,pac模式、自动模式等均无效)
'''
url = 'https://cn.torrentkitty.tv/search/'
# url = 'https://www.torrentkitty.tv/search/'
key = sys.argv[1]
scraper = cfscrape.create_scraper()
def create_parser(pageCount: int):
text = str(scraper.get(url + key + "/" + str(pageCount)).content, 'utf-8')
return BeautifulSoup(text,'lxml')
def parse_result(parser):
return parser.select('table#archiveResult > tr')
pageCount = 1
html_parser = create_parser(pageCount)
pages = html_parser.select('div#main > div.wrapper > div.pagination > a')
if len(pages) > 1:
pageCount = int(pages[-2]['href'])
print('pages', pageCount)
results = parse_result(html_parser)
for currentPage in range(2, pageCount + 1):
results += parse_result(create_parser(pageCount))
string = ''
for row in results:
names = row.select('td.name')
dates = row.select('td.date')
magnets = row.select('td.action > a:nth-child(2)')
if len(names) == 1 and len(dates) == 1 and len(magnets) == 1:
name = names[0].text
name = name.replace('[email protected]', '')
#print(name)
string += '[%s] %s\n%s\n\n'%(name, dates[0].text, magnets[0]['href'])
fileW = open(key + ".txt", "w")
fileW.write(string)
fileW.close()
print('done')
1
https://gitee.com/harvey520/torrentkittySearch.git
git@gitee.com:harvey520/torrentkittySearch.git
harvey520
torrentkittySearch
torrentkittySearch
master

搜索帮助