经验大分享:python练习:从番号到封面

简介: 经验大分享:python练习:从番号到封面

我不知道为什么会选择python去学习,可能和前阵子有在v2ex看到有同学用python抓磁力的有关,今天12点起床闲来无事,继续学习吧。

本来也想找个磁力站练练手抓抓magnet的,打开收藏夹的几个站点才发现URL全都加密了。一个个找,终于发现一个可以联手的网站。嘻嘻。

1 #!/usr/bin/env python

2

3 #coding :UTF-8

4 auther = 'mashaz'

5 import urllib,urllib2

6 import sys

7 import re

8 print 'Thank ** a lot'

9 url = ''

10 key = sys.argv【1】

11 key_len=len(key)

12 unicode(key,'utf-8')

13 url = url + key

14 req = urllib2.Request(url)

15 req.add_header('User-Agent','Mozilla 5.10')

16 fo = urllib2.urlopen(req)

17 html = str(fo.read())

18 #print html

19

20 wait = re.compile(r'')

21 image1 =re.findall(wait,html)

22 #print image1【0】

23

24 r_detail = re.compile(r'')

25 image_detail = re.findall(r_detail,html)

26 s = image_detail【0】

27 #print s

28 #s detail_web

29

30 req2 = urllib2.Request(s)

31 req.add_header('User-Agent','Mozilla //代码效果参考:http://www.zidongmutanji.com/zsjx/422975.html

5.10')

32 fod = urllib2.urlopen(req2)

33 html2 = str(fod.read())

34 if(key_len==7):

35 wait2 = re.compile(r'')

36 if(key_len==8):

37 wait2 = re.compile(r'')

38 big_image = re.findall(wait2,html2)

39 #print big_image【0】

40 #print html2

41

42 def getImage(addr):

43 u = urllib.urlopen(addr)

44 data=u.read()

45 splitPath = addr.split('/')

46 fName = splitPath.pop()

47 print fName

48

49 f= open(fName,'wb')

50 f.write(data)

51 f.close()

52

53 addr = big_image【0】

54 getImage(addr)

由于比较少儿不宜,域名我已省去,有兴趣的朋友可以pm我或者稍加修改换成其他站点都OK啦

加上今天的学习,应该学习Python有24小时左右了,加油。

相关文章
|
1天前
|
Python
Python 练习实例30
Python 练习实例30
|
1天前
|
Python
Python 练习实例29
Python 练习实例29
|
2天前
|
Python
Python 练习实例27
Python 练习实例27
|
2天前
|
Python
Python 练习实例26
Python 练习实例26
|
2天前
|
Python
Python 练习实例25
Python 练习实例25
|
3天前
|
Python
Python 练习实例24
Python 练习实例24
|
1天前
|
Python
Python 练习实例28
Python 练习实例28
|
2天前
|
Python
技术经验解读:【Python】torrentParser1.04增加获得磁力链URI功能
技术经验解读:【Python】torrentParser1.04增加获得磁力链URI功能
|
2天前
|
Shell Python
技术经验解读:使用python脚本传递参数:(三种方式可收藏)
技术经验解读:使用python脚本传递参数:(三种方式可收藏)
|
2天前
|
程序员 API 计算机视觉
技术经验解读:【python自动化】02.pywin32库自动操作键鼠(保姆级代码注释)
技术经验解读:【python自动化】02.pywin32库自动操作键鼠(保姆级代码注释)