dousong8187 2013-08-25 16:42
浏览 99
已采纳

如何从php curl访问洋葱网站? [重复]

This question already has an answer here:

I use this code:

$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);

It's returns nothing instantly. Tor is working normally, and site is accessible from tor browser. Edit: I've found that it can't resolve host ("Couldn't resolve host name" error).

</div>
  • 写回答

1条回答 默认 最新

  • dtkf64283 2013-08-25 16:58
    关注

    Well, I've found out that I need to set proxy type to CURLPROXY_SOCKS5_HOSTNAME:

    curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
    

    It works fine.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料