本文整理汇总了Python中pynag.Plugins.PluginHelper.show_legacy方法的典型用法代码示例。如果您正苦于以下问题:Python PluginHelper.show_legacy方法的具体用法?Python PluginHelper.show_legacy怎么用?Python PluginHelper.show_legacy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynag.Plugins.PluginHelper
的用法示例。
在下文中一共展示了PluginHelper.show_legacy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginHelper
# 需要导入模块: from pynag.Plugins import PluginHelper [as 别名]
# 或者: from pynag.Plugins.PluginHelper import show_legacy [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This script collects key figure metrics from hagstofan.is
from pynag.Plugins import PluginHelper, ok, unknown
import requests
from BeautifulSoup import BeautifulSoup
url = 'http://hagstofan.is'
p = PluginHelper()
p.parse_arguments()
p.show_legacy = True
tmp = requests.get(url)
html = tmp.content
soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML_ENTITIES)
keyfigures_table = soup.find('table', {'class': 'keyfigures_small'})
if not keyfigures_table:
p.exit(unknown, "Could not find any table with class=keyfigures_small'")
rows = keyfigures_table.findAll('tr')
for row in rows:
textdata = row.find('td', {'class': 'textdata'})
numberdata = row.find('td', {'class': 'numberdata'})
if not textdata or not numberdata:
continue
# Get the text content out of the <td> cells
示例2: reload
# 需要导入模块: from pynag.Plugins import PluginHelper [as 别名]
# 或者: from pynag.Plugins.PluginHelper import show_legacy [as 别名]
from dateutil.parser import parse
import requests
import sys
import time
from BeautifulSoup import BeautifulSoup
from pynag.Plugins import PluginHelper,ok,warning,critical,unknown
reload(sys)
sys.setdefaultencoding('utf-8')
helper = PluginHelper()
helper.parse_arguments()
helper.show_legacy = True
now = time.time()
url = 'http://hraun.vedur.is/ja/skjalftar/skjlisti.html'
html = requests.get(url).content
soup = BeautifulSoup(html)
tables = soup.findAll('table')
earthquakes = tables[2]
rows = earthquakes.findAll('tr')
header_row = rows.pop(0)
lines = []
recent_earthquakes = 0
major_earthquakes = 0
for row in rows:
columns = row.findAll('td')