用于检查网站标签的 Python 脚本

标签 python html linux scripting cron

我正在尝试弄清楚如何编写网站监控脚本(最后是 cron 作业)以打开给定的 URL,检查标签是否存在,标签是否不存在,或者不包含预期的数据,然后将一些数据写入日志文件,或发送电子邮件。

标签应该是类似或相对类似的东西。

有人有什么想法吗?

最佳答案

你最好的选择是查看BeautifulSoup .像这样:

import urllib2
from BeautifulSoup import BeautifulSoup

page = urllib2.urlopen("http://yoursite.com")
soup = BeautifulSoup(page)

# See the docs on how to search through the soup. I'm not sure what
# you're looking for so my example stops here :)

之后,通过电子邮件发送或记录它是非常标准的费用。

关于用于检查网站标签的 Python 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2610395/

相关文章:

python - Python中车辆位置估计的卡尔曼滤波器参数定义

python - 通过 python 访问谷歌帐户

linux - 是否可以从一个点创建多个独立的持久 VPN 连接?

linux - 在汇编中执行后如何将 execve 系统调用的输出返回到寄存器或堆栈?

python - 在 python 中从树构建语法

python - 如何读取 Pandas 中的非结构化 csv

javascript - 如何防止 HTML Canvas 上的缩小

javascript - 从数组中提取随机字符串并插入句子

html - 使用 viewBox 缩小 svg 图像

linux - Python 的 C 扩展中的 SIGSEGV