【问题标题】:How to access onion sites from php curl? [duplicate]如何从 php curl 访问洋葱站点? [复制]
【发布时间】:2013-08-28 04:24:50
【问题描述】:

我使用这个代码:

$this->curl = curl_init();
        curl_setopt($this->curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
        curl_setopt($this->curl, CURLOPT_TIMEOUT, 60);
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->curl, CURLOPT_PROXY, '127.0.0.1:9050');
        curl_setopt($this->curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
        curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($this->curl, CURLOPT_URL, "http://some-onion-site.onion");
    $contents = curl_exec($this->curl);

它会立即返回任何内容。 Tor 工作正常,可以从 Tor 浏览器访问网站。 编辑:我发现它无法解析主机(“无法解析主机名”错误)。

【问题讨论】:

  • 使用curl_error() 看看出了什么问题
  • @Pekka웃 我已经编辑了这个问题。它无法解析主机名。

标签: php curl tor


【解决方案1】:

好吧,我发现我需要将代理类型设置为 CURLPROXY_SOCKS5_HOSTNAME:

curl_setopt($ch, CURLOPT_PROXYTYPE, 7);

效果很好。

【讨论】:

    猜你喜欢
    • 2018-07-28
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    • 2014-10-15
    • 2014-06-09
    相关资源
    最近更新 更多