2

i am working on one project and i have a problem with one thing. Webpage that i am going to screen scrape have a ~5-10 sec loading time because of high amount of data.

When i am trying screen scrape with PHP Simple HTML DOM Parser i got no results. Screen is blank. All elements i use is ok, because when i enter another page from the same website which has exactly the same code in the few start lines everything is working.

Is there any chance to wait for website finish loading and then screen scrape.

Thanks

My code is:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
error_reporting(0);

include_once('../../simple_html_dom.php');

function scraping_slashdot() {
    // create HTML DOM
    $html = file_get_html('http://www.examplepage.com/');

    // get article block
    foreach($html->find('div[id="rightBlock"]') as $article) {
        // get title1
        $item['title1'] = $article->find('div.[class="inputHead"]', 0)->plaintext;

        $ret[] = $item;
    }


    // clean up memory
    $html->clear();
    unset($html);

    return $ret;
}

// -----------------------------------------------------------------------------
//output
$ret = scraping_slashdot();

foreach($ret as $v) {

    echo $v['title1'];

}
?>
</body>
</html>
4
  • Check other similar questions before posting a new one... ie: stackoverflow.com/q/7620955/1519058 Commented Jul 14, 2014 at 13:07
  • 1
    I checked but nothing resolve my problem. Is it possible to add sleep(); somewhere in the code? I am trying with few combinations but can't make it to work. Commented Jul 14, 2014 at 13:26
  • Try to increase the MAX_FILE_SIZE, if still no luck, try to use curl instead as chown in this example: stackoverflow.com/a/21186309/1519058 Commented Jul 14, 2014 at 13:50
  • @Rhck, did you solve this issue? Commented Feb 18, 2019 at 11:59

1 Answer 1

0

have you tried using jquery? you can complete a function once the page has loaded by adding:

$(document).ready()
Sign up to request clarification or add additional context in comments.

3 Comments

Nop. I am new at this and have no idea how to do that. Can you give me example with code above?
after googling, i have found this tutorial which may be able to help code.tutsplus.com/tutorials/…
It's a php question NOT a js one !

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.