douxingmou4533 2017-07-22 06:56
浏览 143

504 php curl_setopt中的网关超时

I am trying to hit the website url on the proxy url using a php code. I get it from google and trying to use it but when I run this code I am getting

504 Gateway Time-out The server didn't respond in time.

I am not able to find out real reason behind this error what I have to do for this .. Here is the code which I am using

<?php
$curl = curl_init();
$timeout = 3000;
$proxies = file("proxy.txt");
$r="https://abcdefgh.com";
// Not more than 2 at a time
for($x=0;$x<25; $x++){
    //setting time limit to zero will ensure the script doesn't get timed out
    set_time_limit(0);

    //now we will separate proxy address from the port
    //$PROXY_URL=$proxies[$getrand[$x]];
    echo $proxies[$x];
    curl_setopt($curl, CURLOPT_URL,$r);
    curl_setopt($curl , CURLOPT_PROXY , $proxies[$x]);
    curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($curl, CURLOPT_REFERER, "http://google.com/");
    $text = curl_exec($curl);

    echo "Hit Generated:";
    echo $x;

}

?>
  • 写回答

1条回答 默认 最新

  • dsgd4654674 2017-07-22 06:57
    关注

    You need to define the type of proxy. To me it looks you use HTTP proxy.

    评论

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state