savepic

#-*-coding:utf-8-*-

from lxml import etree
import requests
from urllib import urlretrieve
import os

def getHtml(html):
novelcontent = requests.get(html).content
return etree.HTML(novelcontent)

source = getHtml("http://www.cabintu.com")


urllist = source.xpath('//li[@class="airline"]/a')


for i in urllist:

url = i.attrib['href']
sources = getHtml(url)
picurl = sources.xpath('//img[@class="plane"]')


for j in picurl:
urls = j.attrib['src']

picurls = "http://www.cabintu.com" + urls

filename = os.path.basename(picurls)

urlretrieve(picurls,'D:\\pic\\'+'%s'%filename)




posted on 2016-11-28 19:38  chinxfin  阅读(324)  评论(0编辑  收藏  举报

导航