Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 匹配多个';id';将正则表达式与HTML::TreeBuilder结合使用的值_Python_Regex_Dictionary_Tree_Html Tree - Fatal编程技术网

Python 匹配多个';id';将正则表达式与HTML::TreeBuilder结合使用的值

Python 匹配多个';id';将正则表达式与HTML::TreeBuilder结合使用的值,python,regex,dictionary,tree,html-tree,Python,Regex,Dictionary,Tree,Html Tree,我有一个数组中的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

我有一个数组中的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>

这会得到我想要的。

你知道,
dictionary=dict(zip(TITLES,url))
之类的。你说了你想要的,但问题是什么?@mrhobo,请看我的编辑。给我们更多ID。如果你给我们一个字符串的例子而不告诉我们id是什么,我们就找不到模式。@Hobo先生,什么?真正地我一定很难解释。。。好的,试试这个,看看我的编辑——正在进行中。
<?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>
$tree->look_down( _tag => 'p' , id => "abc123.*xyz789")->as_text; # NOT SURE HOW TO MAKE AN ARRAY OF MATCHES...
my $match = $tree->look_down( _tag => 'p' , id => qr{abc123.*xyz789} )->as_text;