【问题标题】:CRON JOB PHP VISIT URLsCRON 作业 PHP 访问 URL
【发布时间】:2015-09-27 22:01:43
【问题描述】:

我正在尝试设置一个 cron 作业以每天访问多个 url。我已经在我的 plesk 界面中安排了访问 .php 文件的命令,它访问了请求的文件 OK。

我将在我的服务器上的 .php 文件中使用什么脚本来访问网址?

会不会是……

wget -q -O- http://www.example.com
wget -q -O- http://www.example.com/page

感谢您的帮助。

【问题讨论】:

    标签: php cron centos plesk


    【解决方案1】:

    如果您尝试访问 url/从 URL 中提取信息,为什么不使用 cURL?

    $ch = curl_init(); 
    // set url 
    curl_setopt($ch, CURLOPT_URL, "example.com"); 
    
    //return the transfer as a string 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    
    // $output contains the output string
    $output = curl_exec($ch); 
    // close curl resource to free up system resources 
    curl_close($ch); 
    

    【讨论】:

      猜你喜欢
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-15
      • 2012-07-06
      • 1970-01-01
      • 2019-04-21
      相关资源
      最近更新 更多