【问题标题】:Send cURL requests through tor?通过 tor 发送 cURL 请求?
【发布时间】:2015-01-30 07:41:31
【问题描述】:

我有一些代码可以向网站发送 curl 请求,但目前它只有一个网站,我不希望他们错误地禁止我的服务器 IP。无论如何我可以通过 Tor 网络发送这些 cURL 请求吗?

我需要什么软件?

运行 CentOS 6.5

public function checkLogin2($email, $password, $cookiefile){
        $cookiefile = 'cookies/'.$cookiefile;
        $handle = fopen($cookiefile, 'w+');
                #$proxy = 'proxy-nl.privateinternetaccess.com:1080';
                #$us = 'x9597458:Th3hXjVyuD';
        $this->_curl->setCookieFile($cookiefile);
        #$this->_curl->addOption(CURLOPT_PROXY, $proxy);
        #$this->_curl->addOption(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
                #$this->_curl->addOption(CURLOPT_PROXYUSERPWD, $us);
        $this->_curl->setUserAgent('FreshAndroidApp-1.3.1');
        $this->_curl->addHeader('Content-Type', 'application/x-www-form-urlencoded');
        $this->_curl->addHeader('Cookie', 'JSESSIONID=' . strtoupper(md5(time())));
        $this->_curl->addHeader('Cookie2', '$Version=1');

        try {
        $HTML = $this->_curl->post("URL HERE",
                            array('password' => $password, 
                                  'emailAddress' => $email
                            ));         

        if(!self::isJson($HTML)){
            return '{"status":"uncheck", "msg":"<font color="red"><b>Uncheck</b></font> => ' .$email.'|'.$password.'"}';

        }       
        $resp = json_decode($HTML);


        if($resp->{'status'} == "success"){
            $details = $this->_curl->get('URL HERE');
            return $details;
        } else if ($resp->{'status'} == "failure"){
            return '{"status":"failure"}';
        }
        fclose($handle);    
        } catch (CurlWrapperException $e){
            return '{"status":"socksfailure", "msg":"'.$proxy. ' => Die or timeout"}';
        }   
        fclose($handle);
    }

【问题讨论】:

    标签: php curl centos tor


    【解决方案1】:

    您需要安装并运行 TOR,如以下链接所述:https://www.torproject.org/docs/rpms.html.en

    那么,如果你的代码是正确的(我对 PHP 了解不多),那就这样做吧:

        $this->_curl->addOption(CURLOPT_PROXY, 127.0.0.1:9050);
        $this->_curl->addOption(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    

    因为 TOR 代理默认在端口 9050 上运行。 如果您在另一台机器上运行 TOR,您也可以使用另一个 IP 而不是 127.0.0.1。

    我认为这应该可行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-26
      • 2018-06-21
      • 2017-04-23
      • 1970-01-01
      • 2018-06-16
      • 2014-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多