Python使用socks代理
Python使用socks代理
参考:How to make python Requests work via socks proxy - Stack Overflow
使用pysocks库 - Jim's answer
As of requests version 2.10.0, released on 2016-04-29, requests supports SOCKS.
It requires PySocks, which can be installed with pip install pysocks.
Install:
pip install pysocks
or
pip install -U requests[socks]
Example usage:
import requests
proxies = {'http': "socks5://myproxy:9191"}
requests.get('http://example.org', proxies=proxies)
requests.exceptions.ConnectionError报错 - Mahmoud Hashemi's answer
In case someone has tried all of these older answers, and is still running into problems like:
requests.exceptions.ConnectionError:
SOCKSHTTPConnectionPool(host='myhost', port=80):
Max retries exceeded with url: /my/path
(Caused by NewConnectionError('<requests.packages.urllib3.contrib.socks.SOCKSConnection object at 0x106812bd0>:
Failed to establish a new connection:
[Errno 8] nodename nor servname provided, or not known',))
It may be because, by default, requests is configured to resolve DNS queries on the local side of the connection.
Try changing your proxy URL from socks5://proxyhost:1234 to socks5h://proxyhost:1234. Note the extra h (it stands for hostname resolution).
The PySocks package module default is to do remote resolution, and I'm not sure why requests made their integration this obscurely divergent, but here we are.
Python使用socks代理的更多相关文章
- python抓取数据,python使用socks代理抓取数据
在python中,正常的抓取数据直接使用urllib2 这个模块: import urllib2 url = 'http://fanyi.baidu.com/' stream = urllib2.ur ...
- [转]使用 mitmproxy + python 做拦截代理
使用 mitmproxy + python 做拦截代理 本文是一个较为完整的 mitmproxy 教程,侧重于介绍如何开发拦截脚本,帮助读者能够快速得到一个自定义的代理工具. 本文假设读者有基本的 ...
- 【转载】SOCKS代理:从***到内网漫游
原文:SOCKS代理:从***到内网漫游 本文原创作者:tahf,本文属FreeBuf原创奖励计划,未经许可禁止转载 之前在Freebuf上学习过很多大牛写的关于Tunnel.SOCKS代理.***等 ...
- steam linux 使用socks代理
环境:Ubuntu 15.10 64bit,Steam:built:May 10 2016 需要的工具:ssh/shadowsocks等socks5代理,tsocks ---------------- ...
- 内网隧道与SOCKS代理思路总结
早就想总结一下这部分内容了,总是有其他事情卡住,一直拖到现在 内网中有很多边界设备,比如防火墙.这种边界设备会控制内部主机的对外连接,一般会仅允许某些种类的端口开放或某种数据流量出入 这就意味着我们只 ...
- redsocks 将socks代理转换成全局代理
redsocks 需要手动下载编译.前置需求为libevent组件,当然gcc什么的肯定是必须的. 获取源码 git clone https://github.com/darkk/redsocks 安 ...
- Mac Aria2 使用Privoxy将socks代理转化为http代理
安装Privoxy 打开终端安装privoxy来实现这里我是通过brew来进行的安装 brew install privoxy 看到这行已经安装成功 ==> Caveats To have la ...
- 使用ssh正向连接、反向连接、做socks代理的方法
ssh -L 219.143.16.157:58080:172.21.163.32:8080 用户名@localhost -p 10142 在 219.143.16.157机器执行 将ssh隧 ...
- Winet API 支持HTTPP/SOCKS代理
源程序 1.Winet API 支持使用IE代理.或者不使用代理.或者使用自定义代理三种方式. 2.使用自定义代理的话,支持HTTP代理,SOCKS代理,但是SOCKS代理不知支持用户名密码,HTTP ...
- 给HttpClient添加Socks代理
本文描述http client使用socks代理过程中需要注意的几个方面:1,socks5支持用户密码授权:2,支持https:3,支持让代理服务器解析DNS: 使用代理创建Socket 从原理上来看 ...
随机推荐
- response status is 500 https://localhost:7129/swagger/v1/swagger.json
SwaggerGeneratorException: Conflicting method/path combination "GET Test" for actions - To ...
- php 滑动图片验证生成
1.话不多说,直接干货,喜欢的希望大家一键三连 <?php namespace App\Model; class VerifyImage { //浮层坐标数组 protected $tailor ...
- maven 通用pom.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http:// ...
- ubuntu20.0.4 安装influxdb
官网:https://docs.influxdata.com/influxdb/v2.3/install/?t=Linux1.命令:# Ubuntu/Debian wget https://dl.in ...
- vue 报错Uncaught (in promise) cancel
解决:.catch()不能省略(因为取消操作时,无法捕获) .then(res => {...}) .catch(()=>{});(then之后把catch加上)
- js 操作(数字前端去0、文字去除空格、截取字符串、保留几位小数、数字不足位数前补0)
1.数字前端去0 var num = number.replace(/\b(0+)/gi,"") 2.文字去除空格 var str = str.replace(/(^\s*)|(\ ...
- laravel 导入导出(实际上还是php代码实现)
1.导出 public function excel(){ $data=User::all(); $data=json_decode(json_encode($data), ...
- Java jar打包成exe应用程序,可在无JDK/JRE环境下运行
转载自 https://blog.csdn.net/hao65103940/article/details/106494964 前期准备 一个jar包,没有bug能正常启动的jar包 exe4j,一个 ...
- jquery获取父级容器高度
//获取浏览器显示区域的高度console.log( $(window).height()); //获取浏览器显示区域的宽度console.log($(window).width()); //获取页面 ...
- 记——flask实现全文搜索
参考: flask入门和进阶十(实现全文搜索)已解决:https://blog.csdn.net/chengmo123/article/details/100552287 一.首先安装flask-wh ...