本文整理汇总了Python中login.Login.getPage方法的典型用法代码示例。如果您正苦于以下问题:Python Login.getPage方法的具体用法?Python Login.getPage怎么用?Python Login.getPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类login.Login
的用法示例。
在下文中一共展示了Login.getPage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Scrape
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import getPage [as 别名]
class Scrape(object):
def __init__(self, server):
# initialize server from the config file
self.server = server
self.__login = Login()
# decide upon the rule expression that is supposed to be included in the link that will be used to scrape
def getRule(self, ruletype):
if ruletype.lower() == 'test blocker':
return 'test_blockers'
elif ruletype.lower() == "regression":
return 'regression_prs'
elif ruletype.lower() == "beta blocker":
return 'beta_blocker_prs'
elif ruletype.lower() == "cl1":
return 'CL1'
elif ruletype.lower() == "cl2":
return 'CL2'
elif ruletype.lower() == "il1":
return 'IL1'
elif ruletype.lower() == "il2":
return 'IL2'
# From the list of PRs obtained by scraping dashboard get the count of PRs
def getCount(self, username, ruletype):
dashboard = self.__login.getPage('https://%(1)s.juniper.net/dashboard/matrix/?rules=%(2)s&releases=all&users=%(3)s&feedback=yes&found_during=all' \
% {"1": self.server, "2": self.getRule(ruletype), "3": username})
soup = BeautifulSoup(dashboard)
table = soup.find( "table", {"id":"matrix-table"} )
rows = table.findAll('tr')
tabledata = rows[1].findAll('td')
try:
count = int(tabledata[0].find(text=True))
return count
except Exception, err:
err.message
return 0