我有一个数组中的URL列表:
http://www.site.sx/doc1.html
http://www.site.sx/doc2.html
http://www.site.sx/doc3.html
.
.
.
让我们查看第一页的内容,即doc1.html:
<?xmlversion = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Birds</title>
</head>
<body>
<p>Some bird's feather's aren't actually blue, they're clear.</p>
<!--LOOK HERE--><p id = "abc123FACT1xyz789">There exists an insect that makes 100-decibel sounds.</p>
</body>
</html>
现在,让我们查看第二页的内容,即doc2.html:
<?xmlversion = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cats</title>
</head>
<body>
<p>Moota goes from house to house.</p>
<!--LOOK HERE--><p id = "abc123FACT2xyz789">Falling from a higher altitude might be better than a lower one.</p>
</body>
</html>
doc3.html对于abc123.....xyz789
值具有相同的ìd
- 类型的模式,我的数组中的其余页面也是如此。我想捕获每个文本内容。每个文档中只有一个id
值具有此特定模式。当然,实际上文档中有多个id
值,但为了简单起见,我们可以忽略它。
BIG PICTURE:我想把每场比赛都这样:
$tree->look_down( _tag => 'p' , id => "abc123.*xyz789")->as_text; # NOT SURE HOW TO MAKE AN ARRAY OF MATCHES...
答案 0 :(得分:0)
my $match = $tree->look_down( _tag => 'p' , id => qr{abc123.*xyz789} )->as_text;
这将得到我所追求的目标。