0

我已经有几个脚本从不同的服务器中提取信息完美地工作了大约一年。

最近,他们似乎改变了一些东西,simple_html_dom 和 curl 都无法工作,导致打开流失败:HTTP 请求失败!错误或只是冻结。

有时,我可以成功通过一个请求,但只有一个。问题是脚本的性质需要来自该服务器的多个请求。

我要拉的页面是http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/cntnBscSrch.do?textField1=otimo&selectField1=tmlookup_ext&useblg=bscSrch.do%3Flang%3Deng&languageDirection=f&lang= eng&submitButton=搜索&selectMaxDoc=1000000&selectDocsPerPage=1000000

真的很感激任何帮助

这是代码的简化版本,也会导致同样的问题:

<?php
require("simple_html_dom.php");

function file_get_contents_curl($url) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
      curl_setopt($ch, CURLOPT_URL, $url);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
}

$link="http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/cntnBscSrch.do?textField1=otamo&selectField1=tmlookup_ext&useblg=bscSrch.do%3Flang%3Deng&languageDirection=f&lang=eng&submitButton=Search&selectMaxDoc=1000000&selectDocsPerPage=1000000";

$html = file_get_html($link);
echo "SIMPLE HTML DOM:<br>".$html;

$html = file_get_contents_curl($link);
echo "CURL:<br>".$html
?>
4

0 回答 0