python urllib socks5 auth username password 設定
在使用一批socks5帶使用者名稱和密碼的代理的時候需要用到urllib這個python庫
# https://pypi.org/project/PySocks/
import urllib
import socks
import socket
# from urllib import request
from urllib.error import URLError
username = "username"
password = "password"
ip = "107.*.*.122"
port = 11336
proxy = "socks5://{username}:{password}@{ip}:{port}".format(username=username,password=password,ip=ip,port=port)
socks.set_default_proxy(socks.SOCKS5, ip, port,username=username,password=password)
socket.socket = socks.socksocket
url = 'http://httpbin.org/get'
try:
req = urllib.request.Request(url=url,headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'})
response = urllib.request.urlopen(req)
# response = request.urlopen(url)
print(response.read().decode('utf-8'))
except URLError as e:
print(e)
// 相應結果
{
"args": {},
"headers": {
"Accept-Encoding": "identity",
"Host": "httpbin.org",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-5fd8a0d5-6f4cb76331f614657da833e8"
},
"origin": "107.*.*.122",
"url": "http://httpbin.org/get"
}
參考:https://pypi.org/project/PySocks/
相關文章
- The password supplied with the username Domain\UserName was not correct. Verify that it was entered ...AI
- WCF Security:authentication based on Username/Password - Part I
- Apache Httpd Server 2.2 Auth Password FormatsApachehttpdServerORM
- 解決安裝Redis之後設定密碼,報(error) ERR Client sent AUTH, but no password is setRedis密碼Errorclient
- WCF Services Sample: Authenticate Silverlight Client based on UserName and Passwordclient
- Redis設定Auth認證保護Redis
- ORA-01017:invalid username/password; logon deniedGo
- [備忘]Redis執行出現Client sent AUTH, but no password is setRedisclient
- Python3 urllib 與 Python2 urllib的變化Python
- ConfigureGC.pl Reports - Invalid Username/Password. (文件 ID 602750.1)GC
- 【YashanDB資料庫】YAS-02143 invalid username/password, login denied資料庫
- laravel 使用 auth:admin 中介軟體後, 會把 Auth->defaultDriver 設定為 adminLaravel
- Python中urllib和urllib2庫的用法Python
- Python urllib/urllib2 的簡單包裝Python
- SourceTreet提交時顯示remote: Incorrect username or password ( access token )(4種解決辦法)REM
- Python模組之urllib模組Python
- Python模組學習:urllibPython
- RMAN-04006: error from auxiliary database: ORA-01017: invalid username/password;ErrorUXDatabase
- AD Administration error:ORA-01017: invalid username/password; logon deniedErrorGo
- Python urllib HTTP頭注入漏洞PythonHTTP
- 學習Python的urllib模組Python
- python urllib 基礎之 3Python
- python urllib 基礎 get ajaxPython
- Python 爬蟲十六式 - 第二式: urllib 與 urllib3Python爬蟲
- sqlplus / as sysdba報錯ORA-01017: invalid username/password; logon deniedSQLGo
- EBS在測試時報 APP-FND-01516: Invalid application username,password,or database.APPDatabase
- python爬蟲基礎之urllibPython爬蟲
- laravel8.5用自帶的auth登入功能,預設驗證的password密碼欄位,怎麼修改Laravel密碼
- 【DG】搭建DG時報錯:ORA-01017、ORA-17627、ORA-17629 invalid username/password
- python小專題——urllib2模組Python
- auth
- URL username 屬性
- Auth、OAuth 和 Auth 什麼是?OAuth
- MASA Auth - SSO與Identity設計IDE
- 2.python爬蟲基礎——Urllib庫Python爬蟲
- Python3爬蟲實戰(urllib模組)Python爬蟲
- python爬蟲常用庫之urllib詳解Python爬蟲
- Python爬蟲學習(1): urllib的使用Python爬蟲