Python3 - Requests with Sock5 proxy

前端 未结 2 1702
日久生厌
日久生厌 2021-02-08 07:25

Is there a way to use sock5 proxy to use TOR with requests? I know that requests only use http proxy...

import requests
r = requests.get(\'http://www.google.com\         


        
2条回答
  •  忘掉有多难
    2021-02-08 08:14

    I think at the moment requests works with socks5 out of the box.

    import requests
    
    url = 'https://example.com'
    proxies = {'http': 'socks5://127.0.0.1:9150',
               'https': 'socks5://127.0.0.1:9150'}
    r = requests.get(url, proxies=proxies)
    

提交回复
热议问题