Menu

#48 Takes so long to parse it ?

v1.0_(example)
closed
None
1
2019-09-22
2019-09-01
pipiscrew
No

Hi,

always hit the max_exec_time...

$html = file_get_html("...");

$ret = $html->find('.lazy');

print_r($ret);

or

$html = file_get_html("...");

foreach($html->find('img') as $element) 
echo $element->src . '<br>';

please advise.

Discussion

  • pipiscrew

    pipiscrew - 2019-09-02

    forgot to mention, because something wrong with the SSL in specific site, I modify the lib, to get the source using the following function :

    src - https://stackoverflow.com/a/12446906/1320686
    
    function getSslPage($url) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    
     
  • LogMANOriginal

    LogMANOriginal - 2019-09-21

    The site is protected against bots. When you access the page, it first sends a dummy page, which loads the full page after making sure it runs in a browser. If you install a plugin to disable JavaScript, the following message will appear:

    Pardon Our Interruption
    
    As you were browsing something about your browser made us think you were a bot. There are a few reasons this might happen:
    
    
    - You're a power user moving through this website with super-human speed.
    - You've disabled cookies in your web browser.
    - A third-party browser plugin, such as Ghostery or NoScript, is preventing JavaScript from running. Additional information is available in this support article.
    
    To regain access, please make sure that cookies and JavaScript are enabled before reloading the page.
    

    The same data is received by the parser. There is unfortunately nothing we can do about that. Here is my script for reference:

    <?php
    include_once 'simple_html_dom.php';
    
    $url = "...";
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_ENCODING, '');
    curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    
    $doc = curl_exec($ch);
    curl_close($ch);
    
    $html = str_get_html($doc);
    
    echo $html->plaintext;
    
     
    ❤️
    1

    Last edit: LogMANOriginal 2019-09-22
  • LogMANOriginal

    LogMANOriginal - 2019-09-21
    • status: open --> closed
    • assigned_to: LogMANOriginal
     
    👍
    1

Log in to post a comment.