当前位置:   article > 正文

python 爬取种子_利用python代码爬取torrentkitty上的种子

torrentkitty

话不多说上源代码,只要把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页就这样了。。。。

0f93e9b276b382f091a3b09fb505f515.png

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/71557
推荐阅读
相关标签
  

闽ICP备14008679号