使用php从静态html文件中提取/刮取javascript window.open

使用php从静态html文件中提取/刮取javascript window.open,php,web-scraping,simple-html-dom,scrape,Php,Web Scraping,Simple Html Dom,Scrape,我正试图抓取一堆本地html文件。每个文件中都嵌入了一段javascript,具有不同的window.open路径,如下所示: <script> function goTo() { if (document.getElementById('somedomain').checked) { window.open("http://www.somedomain.com"); } if (document.getElementById('visit').checked) { windo

我正试图抓取一堆本地html文件。每个文件中都嵌入了一段javascript,具有不同的window.open路径,如下所示:

<script>

function goTo() {

if (document.getElementById('somedomain').checked) {
window.open("http://www.somedomain.com");
}

if (document.getElementById('visit').checked) {
window.open("http://extract-this-url.com/?somevar=12345&anothervar=59305&etc=etc");
}

}
</script>

函数goTo(){
if(document.getElementById('somedomain')。选中){
窗口打开(“http://www.somedomain.com");
}
if(document.getElementById('visit')。选中){
窗口打开(“http://extract-this-url.com/?somevar=12345&anothervar=59305&etc=etc");
}
}
我正在尝试提取第二个URL——它将是每个文件的不同URL(第一个“somedomain”URL也是如此)

我一直在看,但它看起来不能做嵌入HTML文件中的javascript

有什么好办法吗?

只需使用regexp:

preg_match('#visit.*?window\.open\("(.*?)"#is',$text,$matches);
print_r($matches);

似乎无法让它工作-只是得到一个空数组。我假设在这个例子中,$text就是要从中提取的文件的HTML源代码,对吗?我的错误是,它应该是#is no#。现在编辑它=)HTML解析器解析HTML,而不是JavaScript;-)