我想做一些简单的单词/句子查找。你知道吗
试过这个:
import urllib
from urllib import request
url = "https://fotka.com/profil/k"
word = "Nie ma profilu"
def search_website(url, word):
page = urllib.request.urlopen(url)
phrase_present = False
for i in page:
if bytes(word, encoding='utf8') in i:
phrase_present = True
print(i)
return phrase_present
finder = search_website(url, word)
print(finder)
看起来效果不错,但是,请解释一下url
。
如果在浏览器中打开:
url = "https://fotka.com/profil/k"
确实存在搜索到的word
,因此返回True
,但如果打开:
url = "https://fotka.com/profil/kkkk"
页面上没有这样的word
,它仍然返回True
。你知道吗
我检查了变量page
的内容,在这两种情况下,它是相同的,而url
是不同的。。。你知道吗
有人知道为什么有解决办法的想法吗?你知道吗
如果您的问题是“如何检查页面上是否有可见的测试?”那么,这可能是你的解决方案
您发布了一个非常广泛的cast,但我认为您正在寻找段落标记之间的数据
<p>
:final_paragraph_data
现在存储包含word
内容的所有句子簇的列表。你知道吗相关问题 更多 >
编程相关推荐