#Author: Mini
#! /usr/bin/env python
Import Urllib.request
Import re
Import Urllib.error
headers= ("User-agent", "mozilla/5.0" (Windows NT 10.0; Win64; x64; rv:56.0) gecko/20100101 firefox/56.0 ")
Opener=urllib.request.build_opener ()
Opener.addheaders=[headers]
Urllib.request.install_opener (opener)
keyword= "Dress"
Key=urllib.request.quote (keyword)
For I in Range (1,101):
Try
Url= "https://s.taobao.com/search?q=" +key+ "&imgfile=&js=1&stats_click=search_radio_all%3A1& Initiative_id=staobaoz_20171003&ie=utf8&bcoffset=4&ntoffset=4&p4ppushleft=1%2c48&s= "+str (i *44)
Data=urllib.request.urlopen (URL). read (). Decode ("Utf-8", "ignore")
Pat1= ' "Pic_url": "//(. *?)"
Pic=re.compile (PAT1). FindAll (data)
Print ("success!")
Print (pic)
For j in range (0,len (pic)):
THISPIC=PIC[J]
Thispicurl= "/http" +thispic
picf= "e:/m/" +str (i) + "." +str (j) + ". jpg"
Urllib.request.urlretrieve (THISPICURL,FILENAME=PICF)
Except Urllib.error.URLError as E:
If Hasattr (E, "code"):
Print (E.code)
If Hasattr (E, "Reason"):
Print (E.reason)
Web crawling (PLUS6) pic mining