1
我想提取的HTML錶鏈接和日期/廢料郵編鏈接,並從以下鏈接的發佈選項卡上相應的日期:網頁抓取從3GPP網址
我可以使用下面的PHP代碼中提取郵編鏈接:
preg_match_all('/<ul class=\"rpRootGroup\">(.*?)<\/ul/s',$specpage,$zipul);
$specul = new domDocument;
@$specul->loadHTML($zipul[0][0]);
$specul->preserveWhiteSpace = true;
$xpathspecul = new DOMXPath($specul);
$rowsUL = $xpathspecul->query('//tr');
$resultul = array();
$zipf = array();
$zipuni = array();
foreach ($rowsUL as $rowul) {
$colsul = $rowul->getElementsByTagName('td');
foreach ($colsul as $colul) {
if($xpathspecul->evaluate('count(.//a)', $colul) > 0) { // check if an anchor exists
$slinkul = $xpathspecul->evaluate('string(.//a/@href)', $colul); // if there is, then echo the href value
}
if (isset($slinkul) && $slinkul!=null){
$resultul[] = $slinkul;
}
}
}
foreach ($resultul as $ziplink){
$chkzip = pathinfo($ziplink, PATHINFO_EXTENSION);
if ($chkzip == 'zip' && $ziplink!==null){
$zipf[] = trim($ziplink);
}
}
$zipuni = array_values (array_unique($zipf));
$ specpage包含使用curl
Sample image of aforementioned Zip link and Date
但是加載的網站,我不能夠提取相應的日期。
此外,我有使用'array_unique'的問題,因爲可以有相同的Zip鏈接,但具有不同的相應日期。但是,如果沒有'array_unique'即時通訊獲得很多多個鏈接。
任何幫助表示讚賞。
太棒了!它效果很好。非常感謝你 – user2034593
非常好。我不知道他想從頁面中提取什麼。我無法破譯圖像。 XML不起作用的原因是HTML標記錯誤太多。所以我爲33個表中的每一個隔離了HTML。即使這些表格也有太多HTML標記錯誤可供XML使用。 – Misunderstood