我想在网页上搜索 <div class="contents">
,然后我想对 foreach
中的数据进行排序 block 并将其保存到一个文件中,我很确定如何执行后者,但我需要有关网页初始搜索的帮助。
谢谢。
附言有多个<div class="contents">
网页上的元素,我将用 foreach
浏览所有这些元素也阻止。
最佳答案
在 PHP 中使用 simple_html_dom 很容易。例如:
$html = file_get_html('http://www.google.com/');
// Find all images
foreach($html->find('img') as $element)
echo $element->src . '<br>';
关于php - 如何使用 PHP 在网页中搜索元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27765206/