URL 长度可以包含 750 个字符。最常用的实际限制是 2000 个字符,这是旧 IE 的限制。
您应该尝试模拟发出请求的 Web 浏览器。请参阅另一个问题。
编辑:在您的代码中使用 CURL
<?php
// include is not a function, don't use parens (also use require instead)
require '../simple_html_dom.php';
$fname = "http://www.myurl.com";
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// don't want to polute your output
//curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $fname);
$result=curl_exec($ch);
$html = new simple_html_dom();
$html->load($result);
$divs = $html->find('h6');
foreach($divs as $element)
{
$title = $element->find('a', 0)->plaintext;
echo $title.'<br>';
}
echo '<br>';