當前位置: 首頁>>代碼示例>>Python>>正文


Python CommonUtils.getSoupFromUrl方法代碼示例

本文整理匯總了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
開發者ID:jinkingmanager,項目名稱:my_python_code,代碼行數:47,代碼來源:playerSpider.py

示例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
開發者ID:jinkingmanager,項目名稱:my_python_code,代碼行數:20,代碼來源:teamSpider.py

示例3: getUrlContent

# 需要導入模塊: import CommonUtils [as 別名]
# 或者: from CommonUtils import getSoupFromUrl [as 別名]
def getUrlContent():
    return CommonUtils.getSoupFromUrl("http://g.hupu.com/nba/daily/boxscore_23325.html")
開發者ID:jinkingmanager,項目名稱:my_python_code,代碼行數:4,代碼來源:PointSpider.py

示例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)
開發者ID:jinkingmanager,項目名稱:my_python_code,代碼行數:5,代碼來源:ScheduleSpider.py

示例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
開發者ID:jinkingmanager,項目名稱:my_python_code,代碼行數:27,代碼來源:spiderTest.py


注:本文中的CommonUtils.getSoupFromUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。