<reponame>Mhh123/spider
import urllib.request

url = 'http://www.baidu.com/s?ie=UTF-8&wd=ip'

# 创建handler
handler = urllib.request.ProxyHandler(proxies={
    'http': '192.168.3.11:8888'
})
# 根据handler创建一个opener
opener = urllib.request.build_opener(handler)

response = opener.open(url)

with open('dali.html', 'wb') as fp:
    fp.write(response.read())

import urllib.request

url = 'http://www.baidu.com/s?ie=UTF-8&wd=ip'

# 创建handler
handler = urllib.request.ProxyHandler(proxies={
    'http': '192.168.3.11:8888'
})
# 根据handler创建一个opener
opener = urllib.request.build_opener(handler)

response = opener.open(url)

with open('dali.html', 'wb') as fp:
    fp.write(response.read())
# 创建handler # 根据handler创建一个opener