# -*- coding: utf-8 -*-
import re
import os
import urllib
def getpic(keyword):
y=1
x=1
if os.path.exists('/%s'%keyword) is False:
os.mkdir('%s'%keyword)
while True:
html = urllib.urlopen('http://image.xxxxxx.com/search/index?tn=xxxximage&word=%s&pn=%s'%(keyword,y))
html1 = html.read()
htmlrule = re.findall('http://.+?\.jpg',html1)
htmlrule1 = list(set(htmlrule))
y=y+60
for line in htmlrule1:
urllib.urlretrieve(line,filename='%s/%s.jpg'%(keyword,x))
a = os.stat('%s/%s.jpg'%(keyword,x))
b = '%.2f'% (a[6]/1024.0)
b1 = float(b)
if b1 < 10:
os.remove('%s/%s.jpg'%(keyword,x))
continue
else:
x=x+1
keyword = raw_input('enter your keyword:')
getpic(keyword)
简单的python抓图小脚本
最新推荐文章于 2024-04-03 09:52:00 发布