我想让程序告诉我我想要的词是否在文本标签中,但我不知道他为什么找不到正确的词.
我正在抓取的页面包含 tr, td 并且我正在寻找的单词是波斯语单词。
这个问题与unicode有关吗?
a=driver.find_elements_by_tag_name('tr')
for item in a:
if 'آنچيتا' in item.text: #the word is in text but can't match
print('find it')
tag_name tr
基本上代表一行。我们不想找到行,因此我们不能使用tag_name
.
改用 xpath :
a = driver.find_elements_by_xpath("//a[contains(text(),'آنچیتا')]")
for item in a:
if 'آنچيتا' in item.text: #the word is in text but can't match
print('find it')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句