【问题标题】:DOM HTML & JS scrape from JS partDOM HTML & JS 从 JS 部分抓取
【发布时间】:2017-03-09 22:10:09
【问题描述】:

我想使用 HTML DOM 解析器从一个页面抓取链接。

另一个网页有这个代码:

$('#vidabc-fast-watch-button').click(function() {
  $('#fast-watch-frame').attr('src','http://vidabc.com/embed-8fyiakzp0ob8.html');
});                     
$('#kingvid-fast-watch-button').click(function() {

  $('#vidwatch-fast-watch-button').click(function() {
    $('#fast-watch-frame').attr('src','');
  });
  $('#estream-fast-watch-button').click(function() {
    $('#fast-watch-frame').attr('src','http://estream.to/embed-2605th4kkypl.html');
  });
  $('#openload-fast-watch-button').click(function() {
    $('#fast-watch-frame').attr('src','http://openload.co/embed/YsaOx8K5Bk0/');
  });

我想将信息抓取到另一个 PHP 页面和preg_match url。 但在 JS 代码中找不到链接。

有什么想法吗?

【问题讨论】:

    标签: javascript php jquery preg-match-all simple-html-dom


    【解决方案1】:

    您可以通过查看 script 标记的文本内容来匹配脚本中的 URL,并在其上启动 preg_match_all

    $scr = $doc->getElementsByTagName('script')[0]->textContent;
    preg_match_all("/http:[\w#\[\]@!$&()*+,;=%:\/.?~-]*/", $scr, $urls);
    
    print_r($urls[0]);
    

    对于给定的示例,这将输出:

    Array
    (
        [0] => http://vidabc.com/embed-8fyiakzp0ob8.html
        [1] => http://estream.to/embed-2605th4kkypl.html
        [2] => http://openload.co/embed/YsaOx8K5Bk0/
    )
    

    看到它在eval.in上运行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-12
      • 2017-02-27
      • 2013-12-26
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 2018-10-13
      相关资源
      最近更新 更多