我目前正在为某些文本搜索网页。我一直在使用的代码:使用Python在{{}}中查找由JavaScript填充的信息
import urllib
import re
find = "All others"
pageChecker = urllib.urlopen("192.168.1.134/dashboard").read()
if find in pageChecker:
print "Search found!"
else:
print "Search not found"
页面的HTML可以找到here。
对于以段落形式填写的任何文本都可以正常工作,但问题在于我试图找到由{{}}填写的信息。例如,有一个叫做
{{story.type}}
当网页被查看时,这显示为一个数字。我怎么知道这个数字是什么?
我认为你可以使用,如果'startswith( '{{')和的endsWith( '}}')'' – mtkilic
re.findall(R'\ {\ {([^ \}] *)\ } \}',pageChecker)'返回所有感兴趣片段的列表。 – DyZ