setiepr's recent timeline updates
setiepr

setiepr

V2EX member #138090, joined on 2015-09-13 16:01:54 +08:00
setiepr's recent replies
Apr 5, 2016
Replied to a topic by yuexiande Python 如何实现 request 指定使用出口 ip
import socket

real_create_conn = socket.create_connection

def set_src_addr(*args):
address, timeout = args[0], args[1]
source_address = ('IP_ADDR_TO_BIND_TO', 0)
return real_create_conn(address, timeout, source_address)

socket.create_connection = set_src_addr

import requests
r = requests.get('http://www.google.com')
Apr 5, 2016
Replied to a topic by yuexiande Python 如何实现 request 指定使用出口 ip
很赞的活动。
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5591 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 01:40 · PVG 09:40 · LAX 18:40 · JFK 21:40
♥ Do have faith in what you're doing.