import urllib.request
import urllib.parse
import re
import os
import random
def get_road(url0):
req=urllib.request.Request(url0)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36')
response=urllib.request.urlopen(req)
html=response.read().decode("utf-8")
result=re.findall(pattern,html)
def get_jiaoyou_url(result,s0):
req=urllib.request.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36')
response=urllib.request.urlopen(req)
html=response.read().decode("utf-8")
print("url_length=",len(urls))
filename='/home/dflx/下载/jiaoyou_photo/'+str(x)+'.png'
urllib.request.urlretrieve(url,filename)
#ur='https://www.jianshu.com/p/407dac18983c'
#urpath="https://www.jianshu.com/c/bd38bd199ec6?order_by=added_at&page="
ur='https://www.jianshu.com/p/189d1b8101e6'
urpath="https://www.jianshu.com/c/bd38bd199ec6?order_by=added_at&page="
allurls=get_jiaoyou_url(result,'https://www.jianshu.com')
url0="https://www.jianshu.com/c/bd38bd199ec6"
#ur='https://www.jianshu.com/p/407dac18983c'
ur='https://www.jianshu.com/p/189d1b8101e6'
url0="https://www.jianshu.com/c/bd38bd199ec6"
allurls=get_jiaoyou_url(result,'https://www.jianshu.com')
req=urllib.request.Request(url0)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36')
response=urllib.request.urlopen(req)
html=response.read().decode("utf-8")