python文件下载

百度云源代码和几k,mm图片分享

下载交友的图片.网站 https://www.jianshu.com/c/bd38bd199ec6

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")
    pattern=re.compile(r'
meizi.png

有500m,应该大概遍历了所有的文章

爬取 http://www.mm29.com/ ,下载图片

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")
    pattern=re.compile(r'

你可能感兴趣的:(python文件下载)