I have a task. The table on this page contains links. In every link, for exampple first, exist one field with email. I must coppy all these emails.
I writing a script using phpQuery.
<?php
header('Content-type: text/html; charset=utf8');
require 'phpQuery-onefile.php';
function parseMail($url){
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
foreach ($doc->find('#table_top > tbody > tr')as $tempmail{
$tempmail = pq($tempmail)
$mail = $tempmail->find("contains('@')");
}
}
function print_arr($arr){
echo '<pre>' . print_r($arr, true) . '</pre>';
}
$url = 'http://www.topscolibucuresti.ro/bucuresti';
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
foreach($doc->find('#table_top > tbody > tr')as $article){
$article = pq($article);
$link = $article->find('a')->attr('href');
parseMail($link);
print_arr($mail);
}
The script shows error but I don't understand why.. What I should to do?
You're getting that error because you've missed a semi-colon.
foreach ($doc->find('#table_top > tbody > tr')as $tempmail{
$tempmail = pq($tempmail)
$mail = $tempmail->find("contains('@')");
There should be a semi-colon after pq($tempmail)