<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once ('../includes/connect.php');
try {
$filter = $db->query("SELECT * FROM procesory");
$check = $filter->rowCount();
echo $check.'<br />';
while($c = $filter->fetch()){
//print_r($c[21].'<br/>');
$source = file_get_contents($c['pURLMorele']);
$doc = new DomDocument();
$file = @$doc->loadHTML($source);
$rows = $doc->getElementsByTagName('span');
foreach ($rows as $row) {
if($row->getAttribute('class') == 'price') {
echo $c['ID'].' - ';
echo $row->nodeValue.' -- OK!<br />';
}
}
}
}
catch (PDOException $e) {
echo 'Something went wrong!<br>'.$e->getMessage();
die();
}
?>
你好:)我需要从每个记录中获取数据库&#34; pURLMorele&#34;列,然后从SPAN与类&#34; price&#34;之间的URL文本中提取,但现在它只能从ID 2到4工作,它会跳过第一条记录。那是为什么?