python 爬取种子_利用python代码爬取torrentkitty上的种子
话不多说上源代码,只要把lxml的库安装下就好了这个程序完全是解放双手,而且没有弹窗网页等困扰__author__ = 'JianqingJiang'# -*- coding: utf-8 -*-import urllib2from lxml import etreeimport ospre_url ='http://torrentkitty/search/tokyohot/'os.chdir('
话不多说上源代码,只要把lxml的库安装下就好了
这个程序完全是解放双手,而且没有弹窗网页等困扰
__author__ = 'JianqingJiang'
# -*- coding: utf-8 -*-
import urllib2
from lxml import etree
import os
pre_url ='http://torrentkitty/search/tokyohot/'
os.chdir('/Users/JianqingJiang/Downloads/')
def steve(page_num,file_name):
url = pre_url + str(page_num)
print url
ht = urllib2.urlopen(url).read()
content = etree.HTML(ht.lower().decode('utf-8'))
mags = content.xpath("//a[@rel='magnet']")
with open(file_name,'a') as p: # '''Note''':Append mode, run only once!
for mag in mags:
p.write("%s \n \n"%(mag.attrib['href'])+"\n") ##!!encode here to utf-8 to avoid encoding
print "%s \n \n"%(mag.attrib['href'])
for page_num in range(0,10):
print (page_num)
steve(page_num, 'steve.txt')
差不多爬了10页就这样了。。。。

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)