![](/img/trans.png)
[英]How to launch PHP file from Javascript without window.open
[英]Extract/scrape a javascript window.open from a static html file using php
我正在尝试抓取一堆本地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>
我正在尝试提取第二个URL-每个文件将是一个不同的URL(第一个“ somedomain” URL也是如此)。
我一直在看SimpleHTMLDOM,但是看起来它不能做嵌入HTML文件中的javascript。
有什么体面的方法吗?
只需使用一个正则表达式:
preg_match('#visit.*?window\.open\("(.*?)"#is',$text,$matches);
print_r($matches);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.