Connect to .onion websites on tor using python?

蹲街弑〆低调 提交于 2019-11-29 13:44:00

Try to avoid the monkey patching if possible. If you're using modern version of requests, then you should have this functionality already.

import requests
import json

proxies = {
    'http': 'socks5h://127.0.0.1:9050',
    'https': 'socks5h://127.0.0.1:9050'
}

data = requests.get("http://altaddresswcxlld.onion",proxies=proxies).text

print(data)

It's important to specify the proxies using the socks5h:// scheme so that DNS resolution is handled over SOCKS so Tor can resolve the .onion address properly.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!