我正在使用simplehtmldom而我正试图从网站上获取所有链接。这是我的剧本:
include('simplehtmldom/simple_html_dom.php');
// get DOM from URL or file
$html = file_get_html('http://example.com/urls/');
// find all a tags
foreach($html->find('a') as $e)
echo $e->href . "\n";
我得到的是 urls 的完整列表,但其中一些以%3F 结尾,其中可能有一个字符串。类似的东西:
http://example.com/urls/%3F
而不是:
http://example.com/urls/foo
我做了一些研究,似乎需要在 Apache服务器上完成修复,但我无法访问它,我有什么办法可以修复它吗? / p>
答案 0 :(得分:2)
只需解码传入的网址:
echo urldecode($e->href)."\n";
它将为字符串提供已解码的URL。