這是我的代碼來抓取所有的pdf鏈接,但它不起作用。如何從這些鏈接下載並保存到我的電腦上的文件夾?如何從html鏈接抓取並下載所有pdf文件?
<?php
set_time_limit(0);
include 'simple_html_dom.php';
$url = 'http://example.com';
$html = file_get_html($url) or die ('invalid url');
//extrack pdf links
foreach($html->find('a[href=[^"]*\.pdf]') as $element)
echo $element->href.'<br>';
?>
它看起來像你有一個錯字,在foreach循環中,$ htnl應該是$ html。如果這不在你的原始代碼中,你得到的錯誤究竟是什麼? – ggreiner 2012-02-01 22:05:48
「does not work」>。< – 2012-02-01 22:12:15
@ggreiner在我的ori代碼中,沒有錯別字,對不起。我錯過了這裏的錯字。空白結果在我的網頁 – puresmile 2012-02-01 22:54:06