【发布时间】:2022-01-19 01:08:25
【问题描述】:
我有一个域,我想对其进行广泛搜索,除了结尾之外的所有 URL 都相同,我已将其编译到一个列表中。
目标是搜索这些页面中的每一个并识别返回“未找到页面”错误的页面,并将它们返回到控制台 - 我的搜索将是:
<h1 class="center error-page-center" id="error-message">Oops! We couldn’t find what you wanted.</h1>
我一直在尝试使用 BeutifulSoup 来做到这一点,但到目前为止无济于事
import psycopg2
from bs4 import BeautifulSoup
for page in pages:
page = connection.cursor.execute("select concat('https:mywebsite/',integervalue) as url from table")
search = soup.find_all(class_="center error-page-center"):
if len(search)>0:
print ("Needs removal")
考虑到我要搜索几千页,还有其他更有效的方法吗?
我的代码将导致错误,我更感兴趣的是寻找有关如何在 URL 列表中搜索特定文本正文的任何建议。 谢谢
【问题讨论】:
标签: python beautifulsoup