本文整理汇总了Python中CommonUtils.getSoupFromUrl方法的典型用法代码示例。如果您正苦于以下问题:Python CommonUtils.getSoupFromUrl方法的具体用法?Python CommonUtils.getSoupFromUrl怎么用?Python CommonUtils.getSoupFromUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonUtils
的用法示例。
在下文中一共展示了CommonUtils.getSoupFromUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTeamsInfo
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getSoupFromUrl [as 别名]
def getTeamsInfo():
# base url
url = "http://g.hupu.com/nba/players/"
# teams
teams = [
"Spurs",
"Rockets",
"Mavericks",
"Grizzlies",
"Pelicans",
"Clippers",
"Warriors",
"Suns",
"Lakers",
"Kings",
"Blazers",
"Thunder",
"Nuggets",
"Timberwolves",
"Jazz",
"Raptors",
"Nets",
"Knicks",
"Celtics",
"76ers",
"Heat",
"Hawks",
"Wizards",
"Bobcats",
"Magic",
"Pacers",
"Bulls",
"Pistons",
"Cavaliers",
"Bucks",
]
# team dictionary
teamDic = {}
# get all html info divide by teamName
for team in teams:
teamUrl = url + team
teamPlayerInfos = CommonUtils.getSoupFromUrl(teamUrl)
teamDic[team] = teamPlayerInfos
return teamDic
示例2: getTeamUrlContent
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getSoupFromUrl [as 别名]
def getTeamUrlContent():
teamUrl = "http://g.hupu.com/nba/teams/"
#teams
teams = ['Spurs','Rockets','Mavericks','Grizzlies','Pelicans','Clippers',
'Warriors','Suns','Lakers','Kings','Blazers','Thunder','Nuggets',
'Timberwolves','Jazz','Raptors','Nets','Knicks','Celtics','76ers',
'Heat','Hawks','Wizards','Bobcats','Magic','Pacers','Bulls',
'Pistons','Cavaliers','Bucks']
teamDic = {}
for teamName in teams:
url = teamUrl + teamName
teamInfo = CommonUtils.getSoupFromUrl(url)
teamDic[teamName] = teamInfo
return teamDic
示例3: getUrlContent
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getSoupFromUrl [as 别名]
def getUrlContent():
return CommonUtils.getSoupFromUrl("http://g.hupu.com/nba/daily/boxscore_23325.html")
示例4: init
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getSoupFromUrl [as 别名]
def init():
scheduleUrl = "http://nba.sports.sina.com.cn/match_result.php?day=all"
return CommonUtils.getSoupFromUrl(scheduleUrl)
示例5:
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getSoupFromUrl [as 别名]
#coding=utf-8
#!/usr/bin/python
import os, re
import CommonUtils
url = 'http://nba.sports.sina.com.cn/look_scores.php?id=2006110120'
bs = CommonUtils.getSoupFromUrl(url)
# client and home
teams = bs.find_all("a", 'tlogo')
# client
client = teams[0].string.strip()
# home
home = teams[1].string.strip()
# final points
total_points = bs.find_all("td", "num")
# sec points
sec_points = bs.find_all("td", {"bgcolor": "#000000"})
# date
date = url.split("=")[1][0:8]
print client,home,total_points,sec_points