import re import urllib.request import random import os import http.server import http.client from urllib.error import URLError, HTTPError import urllib.parse proxy = [] #定义代理IP列表 def change_proxy(): #创建使用随机某个代理IP地址 proxy_ip = random.choice(proxy) proxy_support = urllib.request.ProxyHandler({ "http":proxy_ip}) opener = urllib.request.build_opener(proxy_support) opener.addheaders = [('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36')] urllib.request.install_opener(opener) print("代理IP: %s" % proxy_ip) def url_open(url): #访问jandan.net网站,如果报错进行重新获取代理IP,最多5次 count = 0 while True: try: if count == "5": print("已经失败了5次,程序退出,重新执行") count += 1
python3 爬煎蛋ooxx妹子图
最新推荐文章于 2021-01-26 17:17:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)