#-*-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)