第一个小爬虫--爬取图片并保存

import urllib.request
import re
import os

def url_open(url):
    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/60.0.3112.113 Safari/537.36')
    response=urllib.request.urlopen(url)
    html=response.read().decode('utf-8')
    return html

def get_img(html):
    p=r'

你可能感兴趣的:(初识python)