|
5鱼币
import urllib.request
import random
listip = ['110.73.0.192:8123','122.114.31.177:808','61.135.217.7:80','61.135.217.7:80','121.231.32.187:808']
url = 'http://www.baidu.com'
proxy_support = urllib.request.ProxyHandler({'http':random.choice(listip)})
opener = urllib.request.build_opener(proxy_support)
opener.addheaders = [{'User-Agent','Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'}]
urllib.request.install_opener(opener)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print(html)
运行之后是这样的:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<h1>Unauthorized ...</h1>
<h2>
IP Address: 221.215.108.74<br>
MAC Address: <br>
Server Time: 2018-05-27 15:58:21<br>
Auth Result: 无效用户.
</h2>
</body>
</html>
有的时候还出现貌似是有道的网站,求大神搭救谢谢!!! |
|