当前位置: 首页>>代码示例>>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;未经允许,请勿转载。