2017-03-09 41 views
0

我想用HTML DOM pharser從一個頁面到另一個頁面的鏈接。從JS部分DOM HTML和JS刮

其他網頁有這樣的代碼:

$('#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代碼裏找不到鏈接。

有什麼想法?

回答

0

你可以通過查看script標籤的文本內容相匹配的腳本中的網址,並推出一個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