-1

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?

6
  • Hey man, I see links, but no email addresses anywhere on the site you provided. What am I missing? Commented Mar 3, 2018 at 10:45
  • Hi. Welcome to Stack Overflow. Have you tried the problem with another, smaller, web page first? (i.e. have you tried reproducing the problem in isolation?) Have a look at the Help Center to see how to write a great question (stackoverflow.com/help/on-topic) Commented Mar 3, 2018 at 11:45
  • @Jonathon, thanks.. I will look. I did't try in isolation. Do you think it'll be resultative? Commented Mar 3, 2018 at 16:10
  • @Yitzhak I need to open every link. And in those pages exist email. For example, first link: topscolibucuresti.ro/scoala/colegiul-national-gheorghe-lazar Commented Mar 3, 2018 at 16:10
  • @engins: what error do you get? Commented Mar 3, 2018 at 17:35

1 Answer 1

0

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)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks.. But now I get new error: Parse error: syntax error, unexpected ';' in C:\OpenServer\domains\parsing\scoli-v1.php on line 9
Your foreach doesn't have a close bracket after $tempmail

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.