Python爬虫代理ip

#设置请求的代理ip: www.goubanjia.com  快代理  西祠代理
#代理ip的类型必须和请求url的协议头保持一致
url = 'https://www.baidu.com/s?wd=ip'

page_text = requests.get(url=url,headers=headers,proxies={'https':'61.7.170.240:8080'}).text

with open('./ip.html','w',encoding='utf-8') as fp:
    fp.write(page_text)