import urllib.request
import re
import os
import time
from urllib.request import urlretrieve
mulu='https://www.xxxxx.com/zh-cn/machines/'
response = urllib.request.urlopen(mulu)
html=response.read().decode('utf-8')
def get_zhang(lianjie,biaoti):
zhang ='https://www.xxxx.com/zh-cn/machines/'+lianjie
response = urllib.request.urlopen(zhang)
html=response.read().decode('utf-8')
pattern=re.compile(u'<ul class="thumbnails">(.*?)</ul>',re.S)
zhang_html=pattern.findall(html)
pattern=re.compile(u'<p class="subtitle">(.*?)</p>')
ddddsss=pattern.findall(html)
os.makedirs('./'+ddddsss[0]+biaoti+'/', exist_ok=True)
for zhengwen in zhang_html:
pattern1=re.compile(u'href="(.*?)"')
ul_html=pattern1.findall(zhengwen)
i=1
for li_html in ul_html:
print(li_html)
ffjpg='https://www.mosca.com'+li_html;
print(ffjpg)
urlretrieve(ffjpg, './'+ddddsss[0]+biaoti+'/img'+str(i)+'.jpg')
i=i+1
pattern=re.compile(u'<a class="no-pjax" href="/zh-cn/machines/(.*?)/">')
mulu=pattern.findall(html)
for zhang in mulu:
biaoti=zhang
print(biaoti)
get_zhang(zhang,biaoti)