网络编程
位置:首页>> 网络编程>> Python编程>> python中requests使用代理proxies方法介绍

python中requests使用代理proxies方法介绍

作者:Winterto1990  发布时间:2023-04-28 09:00:33 

标签:python,requests

学习网络爬虫难免遇到使用代理的情况,下面介绍一下如何使用requests设置代理:

如果需要使用代理,你可以通过为任意请求方法提供 proxies 参数来配置单个请求:


import requests  
proxies = { "http": "http://10.10.1.10:3128", "https": "http://10.10.1.10:1080", }  
requests.get("http://example.org", proxies=proxies)

这里的可以通过ip测试网站进行验证是否成功使用了代理 http://ip.chinaz.com/(查看你访问后的网站的您的IP是多少来判断)

有关requests的出现乱码问题的解决可以查看

python中requests爬去网页内容出现乱码问题解决方法介绍

有关requests的使用cookies问题的解决可以查看

python编程之requests在网络请求中添加cookies参数方法详解

来源:http://blog.csdn.net/winterto1990/article/details/51220307

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com