python3配置socks5代理进行爬取
一.代码
#!/usr/bin/python# -*- coding: UTF-8 -*-
import requests
import socket
import socks
SOCKS5_PROXY_HOST = "xxxx" # socks 代理IP地址
SOCKS5_PROXY_PORT = xxx # socks 代理本地端口
default_socket = socket.socket
socks.set_default_proxy(socks.SOCKS5, SOCKS5_PROXY_HOST, SOCKS5_PROXY_PORT)
socket.socket = socks.socksocket
session = requests.session()
session.keep_alive = False
res=session.get("http://ipconfig.cc/",timeout=5)
print(res.text)
以上是 python3配置socks5代理进行爬取 的全部内容, 来源链接: utcz.com/z/530053.html