使用代理IP

代理IP可以自己去找,也可与去购买,这有一个免费代理ip网址:http://www.66ip.cn/

下面上代码,就这么简洁:

import requests

ip = '220.160.23.136' # 代理IP
port = '8888'         # 端口号

proxies = {
	'http': 'http://%s:%s'%(ip,port),
	'https': 'http://%s:%s'%(ip,port)
}

html = requests.get('http://ip.chinaz.com/',proxies=proxies)
html.encoding = 'utf-8'
print(html.text)

猜你喜欢

转载自blog.csdn.net/a649344475/article/details/81605357