I have the following code which scrapes the text from multiple pages and displays them.
My question for you is how can I take each of those variables and place them into an excel spreadsheet located on the server. For each link, on separate rows.
Like this :
<?php
include_once 'simple_html_dom.php';
$urls = array(
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/01/1150001435/1&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/05/1140001657/1&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/05/1140001657/2&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/01/1150001435/1&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/05/1140001657/1&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/05/1140001657/2&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/01/1150001435/1&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/05/1140001657/1&judet=50',
'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=50/05/1140001657/2&judet=50',
);
function scraping($url) {
// DOM
$html = file_get_html($url);
// articol
if ($html && is_object($html) && isset($html->nodes)) {
foreach ($html->find('/html/body/table') as $article) {
//titlu
$item['titlu'] = trim($article->find('/tbody/tr[1]/td/div', 0)->plaintext);
// tabel
$item['tr2'] = trim($article->find('/tbody/tr[2]/td[2]', 0)->plaintext);
$item['tr3'] = trim($article->find('/tbody/tr[3]/td[2]', 0)->plaintext);
$item['tr4'] = trim($article->find('/tbody/tr[4]/td[2]', 0)->plaintext);
$item['tr5'] = trim($article->find('/tbody/tr[5]/td[2]', 0)->plaintext);
$item['tr6'] = trim($article->find('/tbody/tr[6]/td[2]', 0)->plaintext);
$item['tr7'] = trim($article->find('/tbody/tr[7]/td[2]', 0)->plaintext);
$item['tr8'] = trim($article->find('/tbody/tr[8]/td[2]', 0)->plaintext);
$item['tr9'] = trim($article->find('/tbody/tr[9]/td[2]', 0)->plaintext);
$item['tr10'] = trim($article->find('/tbody/tr[10]/td[2]', 0)->plaintext);
$item['tr11'] = trim($article->find('/tbody/tr[11]/td[2]', 0)->plaintext);
$item['tr12'] = trim($article->find('/tbody/tr[12]/td/div/]', 0)->plaintext);
$ret[] = $item;
}
// memorie
$html->clear();
unset($html);
return $ret;}
}
echo '<pre>';
foreach ($urls as $url) {
$ret = scraping($url);
foreach ($ret as $v) {
echo $v['titlu'] . '<br>';
echo $v['tr2'] . '<br>';
echo $v['tr3'] . '<br>';
echo $v['tr4'] . '<br>';
echo $v['tr5'] . '<br>';
echo $v['tr6'] . '<br>';
echo $v['tr7'] . '<br>';
echo $v['tr8'] . '<br>';
echo $v['tr9'] . '<br>';
echo $v['tr10'] . '<br>';
echo $v['tr11'] . '<br>';
echo $v['tr12'] . '<br>';
echo '<br>';
echo '<br>';
}
}
?>