所有的HREF我想提取所有的HREF:摘自一个HTML链接
https://plugins.svn.wordpress.org/
,并添加到foreach循环。
我使用PHP 简单的HTML DOM解析器http://simplehtmldom.sourceforge.net/
,但它只是超时试图.... 任何帮助,将不胜感激。 这里是我的代码:
// Create DOM from URL or file
$html = file_get_html('https://plugins.svn.wordpress.org/');
// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
OR 使用对象定向方式:
// Create a DOM object
$html = new simple_html_dom();
// Load HTML from a URL
$html->load_file('https://plugins.svn.wordpress.org/');
// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
你应该添加你试过的代码 – RamRaider
为什么不使用正则表达式ssion – king
“超时”可能是因为html内容很大 – king