python 爬取种子_利用python代码爬取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頁就這樣了。。。。
總結
以上是生活随笔為你收集整理的python 爬取种子_利用python代码爬取torrentkitty上的种子的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python爬虫爬取电影网站种子,让你以
- 下一篇: matlab绘制数字滤波器的幅频响应曲线