How can I use Perl to grab text from a web page that is dynamically generated with JavaScript?

后端 未结 5 1792
时光说笑
时光说笑 2020-12-03 03:39

There is a website I am trying to pull information from in Perl, however the section of the page I need is being generated using javascript so all you see in the source is:<

5条回答
  •  爱一瞬间的悲伤
    2020-12-03 04:34

    This might be what your looking for (in PHP):

    $url = 'http://downloadcenter.trendmicro.com/ajx/pattern_result.php';
    
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_POST, 1);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, 'q=patresult_page®=NABU');
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $content = curl_exec($ch);
    curl_close($ch);
    
    echo $content;
    exit;
    

    once you get the content you can use something like: http://code.google.com/p/phpquery/ to parse the results you need or a similar perl equivalent???

    And/or do the parsing yourself.

    FYI: all I did was use firebug to inspect the requests and recreated it with PHP/CURL...

提交回复
热议问题