从<;a>;使用PHP标记

从<;a>;使用PHP标记,php,web-scraping,html-parsing,Php,Web Scraping,Html Parsing,我使用simple_html_dom从html标记中检索href属性值。我正在抓取的数据放在HTML表中。以下代码成功地指向数据并将其显示为超链接 // Include the library to use it. include_once('simple_html_dom.php'); // Get the HTML from the file or website. $html = file_get_html('source.html'); // Put all of the <a

我使用simple_html_dom从html标记中检索href属性值。我正在抓取的数据放在HTML表中。以下代码成功地指向数据并将其显示为超链接

// Include the library to use it.
include_once('simple_html_dom.php');

// Get the HTML from the file or website.
$html = file_get_html('source.html');

// Put all of the <a> tags into an array named $result
$result = $html -> find('table tbody tr td a');

// Run through the array using a foreach loop and print each link out using echo
foreach($result as $link) {
echo $link."<br/>";
}
如何使用上述方法之一从HTML表下的href属性中获取值?该表没有任何类或id在选择器中使用它


注:我也调查了:但没弄明白

我使用了
preg\u match
而不是
preg\u match\u all
,然后使用echo而不是打印。以下代码以第一个链接为目标,并将其显示在屏幕上

preg_match("/href=\"(.*?)\"/i", $html, $matches);
echo $matches;
preg_match("/href=\"(.*?)\"/i", $html, $matches);
echo $matches;