本文整理匯總了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')