使用sockets连接并下载隐藏服务的网页

Use sockets to connect and download webpage of hidden service

socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, "127.0.0.1", 9150, True)
socket = socks.socksocket()
socket.connect(('onionlink.onion', 80))
message = 'GET / HTTP/1.0\r\n\r\n'
socket.sendall(str.encode(message))
reply = socket.recv(4069)
print (reply)

此代码有效,但响应为空...终端打印如下:

b''

有什么问题吗?如何打印隐藏服务的来源?

已解决。需要将 http:// 添加到 message = 'GET / HTTP/1.0\r\n\r\n'

所以现在是:message = 'GET http://onionlink.onion HTTP/1.0\r\n\r\n'