python requests使用socks5的例子

作者:WarmSword 时间:2023-09-14 07:06:45 

网络爬虫由于一个ip频繁访问同一网站,容易返回456或者被长时间封禁。

特别的本机有socks5客户端的设置如下,前提是已经安装了socks5的客户端软件,并且启动起来在固定端口为本机提供服务。

使用前先更新requests版本为支持socks的版本。


pip install -U requests[socks]

import requests

my_proxies={"http":"http://127.0.0.1:1080","https":"https://127.0.0.1:1080"}
resp=requests.get("http://www.some.com",proxies=my_proxies,timeout=5)
print(resp.text)

注意其中的地址协议写的是http和https。

来源:https://blog.csdn.net/junbujianwpl/article/details/79411472

标签:python,requests,socks5
0
投稿

猜你喜欢

  • pandas 两列时间相减换算为秒的方法

    2022-04-15 00:30:07
  • 使用Python点云生成3D网格

    2023-02-06 18:32:45
  • [Oracle] 浅析令人抓狂的ORA-01555问题

    2024-01-21 09:13:28
  • PyCharm安装库numpy失败问题的详细解决方法

    2023-05-18 22:45:16
  • python小技巧——将变量保存在本地及读取

    2022-02-14 23:35:14
  • Python实现对二维码数据进行压缩

    2022-10-22 12:51:59
  • 详细介绍Python中的偏函数

    2022-12-28 08:40:53
  • Python深入浅出分析元类

    2022-01-10 09:09:00
  • python实现求最长回文子串长度

    2022-09-29 13:56:32
  • linux centos7安装mysql8的教程

    2024-01-20 21:52:11
  • AjaxUpLoad.js实现文件上传

    2024-05-11 09:42:07
  • DreamWeaver批处理提高篇

    2007-12-03 11:34:00
  • numpy和tensorflow中的各种乘法(点乘和矩阵乘)

    2022-01-18 05:17:10
  • Python爬取新型冠状病毒“谣言”新闻进行数据分析

    2021-06-14 04:47:33
  • VUE中如何动态绑定类名和样式

    2024-04-26 17:41:35
  • 详细介绍Python中的set集合

    2023-07-26 07:35:03
  • Python中的模块和包概念介绍

    2023-06-06 09:13:53
  • setInterval 和 setTimeout 会产生内存溢出

    2008-03-08 13:10:00
  • 一次现场mysql重复记录数据的排查处理实战记录

    2024-01-17 11:42:28
  • SQL server中字符串逗号分隔函数分享

    2024-01-12 17:20:22
  • asp之家 网络编程 m.aspxhome.com