【问题标题】:PHP: How to use file_get_contents even after sever ip is blockedPHP:即使在服务器 ip 被阻止后如何使用 file_get_contents
【发布时间】:2015-10-15 22:45:28
【问题描述】:

我正在使用 file_get_contents('http://www.somewebsite.com') 函数,但我的服务器 IP 被永久阻止。有什么方法我仍然可以访问该网站?

【问题讨论】:

    标签: php proxy ip


    【解决方案1】:

    是的。将 CURL 与匿名代理一起使用

    $url = 'http://www.somewebsite.com';
    $proxy = 'xxx.xxx.xxx.xxx:xxxx';
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    $curl_page = curl_exec($ch);
    curl_close($ch);
    

    【讨论】:

      猜你喜欢
      • 2020-02-02
      • 1970-01-01
      • 2012-10-06
      • 2015-08-09
      • 1970-01-01
      • 2020-09-26
      • 2021-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多