我想從表格的第一列中獲取名稱和網址http://www.pferd-aktuell.de/fn-service/pferdebranchenbuch/kategorie-uebersicht/13/FN-Vereine,然後遍歷NEXT按鈕以從所有可用網頁中獲取名稱及其URL的所有出現。我試過這樣的東西,它不輸出任何東西。PHP SimpleHTMLDom提取
<?php
include('simplehtmldom/simple_html_dom.php');
ini_set('max_execution_time', 1800);
$url = 'http://www.pferd-aktuell.de/fn-service/pferdebranchenbuch/kategorie-uebersicht/13/FN-Vereine';
$html = file_get_html($url);
$file = 'Titels.txt';
if (!$fp = fopen($file, 'a+')) {
echo "Cannot open file ($file)";
exit;
}
else {
for ($i=1; $i<=25; $i=$i+1)
{
$ret = $html->find('td[class]="withBorder bold"', $i);
fwrite($fp, $ret->plaintext."\n");
}
}
}
提取Titel的和網址後,我計劃通過各那些網址導航,並能夠從那裏太(像的Ort,電子郵件等)提取一些div。
任何示例代碼讓我開始?請:)
從你上面發佈的代碼中,你肯定是在正確的軌道上。找到「下一步」按鈕指向的網址,並將其傳遞給可從網頁中提取所需內容的功能。 – xbonez 2012-03-18 05:37:59