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