bernard_hinault;10967041 wrote:good moring dear php-fans, hello community
i want to parse the site - and get the results out of it:
see this third overview-page
therefore i need to loop over the line 2 - don ยด i!?
<?php
$data = file_get_contents('http://www.educa.ch/dyn/79363.asp?action=search');
$regex = '/Page 1 of (.+?) results/';
preg_match($regex,$data,$match);
var_dump($match);
echo $match[1];
?>
in order to get the details of the pages -
see this first detail-page
see this second detail-page
see this third detail-page
just help me with this seven-liner ๐
update:
and i took some data out of the logic that was produced here:
http://www.phpbuilder.com/board/showthread.php?t=10367522&highlight=scraper
// We'll split it up between those in the contention and those not
preg_match('~(<tr class="ysprow(?:1|2)">.*)<tr><td.*><img.*></td></tr>(<tr class="ysprow(?:1|2)".*>.*</tr>.*)</table>~iUs', $matches[1], $parts);
// $parts[1] are those in contention
// $parts[2] are the other drivers in the field
// Look for all the information for those in contention, save to $matches
preg_match_all('~<tr class="ysprow.*">.*<td.*>.*([\d]*)</td>.*<td.*>([+|-][\d]*)</td><td class=".*padded2px.*".*>.*<a.*>(.*)</a></td>.*<td class=".*ysptblclbg6.*".*>(.*)</td>.*<td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td>.*</tr>~iUs', $parts[1], $matches, PREG_SET_ORDER);
// Look for all the information for the other drivers, store in $matches2
preg_match_all('~<tr class="ysprow.*">.*<td.*>.*([\d]*)</td>.*<td.*>([+|-][\d]*)</td><td class=".*padded2px.*".*>.*<a.*>(.*)</a></td>.*<td class=".*ysptblclbg6.*".*>(.*)</td>.*<td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td><td.*>(.*)</td>.*</tr>~iUs', $parts[2], $matches2, PREG_SET_ORDER);
// Prepare our array for population
$schools = array(
'contention' => array(),
'field' => array()
);
// Add the schools in contention
foreach($matches as $match)
{
$drivers['contention'][$match[1]] = array(
'name' => $match[1],
'adress' => $match[2],
'telefone' => $match[3],
'fax' => $match[4],
'internet' => $match[5],
'e-mail' => $match[6],
'additional infos' => $match[7],
);
}
// Add those schools that are in the rest of the field
foreach($matches2 as $match)
echo '<pre>'.print_r($schools, 1).'</pre>';
well finally i want to put the data in a database -that can be done with the code here http://www.phpbuilder.com/board/showthread.php?t=10367522&highlight=scraper