![](/img/trans.png)
[英]file_get_contents get data after 5 second from loading the web-page
[英]Open web-page, get its contents and follow a link that is in there
我想使用脚本语言(Javascript,PHP)来完成以下任务。
1)我需要在其他窗口中打开一个新的网页,并提供一个URL。
2)在其内容中找到特定链接,然后在同一窗口中将其打开。
Javascript可以实现吗? 如果是,这怎么可能?
PS:第一个链接是动态的,因此我只能打一下它才能打开并阅读。 我注意到,如果我打开它,然后使用PHP的get_contents读取它,则内容会有一些差异。
您可以PHP简单HTML DOM解析器打开页面并找到所需的链接。
查找所有链接的示例:
// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');
// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
方法“ find”具有类似的jQuery sintax。 并且PHP Simple HTML DOM Parser有一个很好的文档示例。
希望对您有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.