|
之前写了个爬取漫画的,发现貌似喜欢的人不是很多呀,在贴吧转了会后发现,正经人们喜欢的是这种类型的由于代码量不大,就不加什么注释了,兄弟们自己研究研究吧
- import time
- import requests
- import os
-
- from urllib3.connectionpool import xrange
-
-
- def get_document(url):
- # print(url)
- try:
- get = requests.get(url)
- data = get.content
- get.close()
- except:
- time.sleep(3)
- try:
- get = requests.get(url)
- data = get.content
- get.close()
- except:
- time.sleep(3)
- get = requests.get(url)
- data = get.content
- get.close()
- return data
-
-
- def download_img(count):
- for i in xrange(count):
- src = "https://lns.hywly.com/a/1/" + str(i)+"/"
- for j in xrange(20):
- document = get_document(src + str(j) + '.jpg')
- if str(document).find("404 Not Found") > 0:
- break
- path = 'd:/SanMu/image/'+str(i)+'/'
- if not os.path.exists(path):
- os.makedirs(path)
- open(path+str(j)+'.jpg', 'wb').write(document)
-
-
- download_img(1000)
复制代码
|
|