Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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 在标记之间查找精确单词_Python_Beautifulsoup - Fatal编程技术网

Python 在标记之间查找精确单词

Python 在标记之间查找精确单词,python,beautifulsoup,Python,Beautifulsoup,关于,我正在搜索文本服务,但它也在搜索未请求的签名服务。我使用下面的代码来获得所需的结果,但不知何故它并不匹配确切的单词 serviceElement = soup.findAll('div', text=re.compile('Service')) 在findAll()方法中,我是否可以同时提到类名和愿望字符串?好的,我找到了一种方法。应用简单的正则表达式规则 serviceElement = soup.findAll('div', text=re.compile('^Service$'))

关于,我正在搜索文本服务,但它也在搜索未请求的签名服务。我使用下面的代码来获得所需的结果,但不知何故它并不匹配确切的单词

serviceElement = soup.findAll('div', text=re.compile('Service'))

findAll()
方法中,我是否可以同时提到类名和愿望字符串?

好的,我找到了一种方法。应用简单的正则表达式规则

serviceElement = soup.findAll('div', text=re.compile('^Service$'))
只是不要删除这个帖子,以防对其他人有帮助