当前位置: 首页>>代码示例>>Python>>正文


Python PyQuery.lower方法代码示例

本文整理汇总了Python中pyquery.PyQuery.lower方法的典型用法代码示例。如果您正苦于以下问题:Python PyQuery.lower方法的具体用法?Python PyQuery.lower怎么用?Python PyQuery.lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyquery.PyQuery的用法示例。


在下文中一共展示了PyQuery.lower方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import lower [as 别名]
def process(url, handle):
    source = PyQuery(url=url)
    siteList = source.find("li.site-listing").find("a")
    content = ""
    for data in siteList:
        domain = PyQuery(data).text()
        if domain.lower() == "more":
            continue
        else:
            #print domain
            content += domain + "\n"
    handle.write(content)
开发者ID:lxw0109,项目名称:ChinaRelatedInAlexaTop1000,代码行数:14,代码来源:methodGeng.py

示例2: fetch_events

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import lower [as 别名]
def fetch_events():
    # some constants for this scrape
    playerID = CONFIG['playerID']
    team = CONFIG['team']
    # use Honolulu time zone so we scrape the right date
    # even during weird baseball
    today = arrow.now('Pacific/Honolulu').date()
    
    r = create_redis_connection()
        
    # scrape the MLB game list page
    game_day_url = DATA_ROOT + 'year_{0}/month_{1}/day_{2}/'.format(today.year, '{:02d}'.format(today.month), '{:02d}'.format(today.day))
    page = PQ(game_day_url)
    # find the links on page
    game_links = [PQ(link).attr('href') for link in page('li a')]
    # we only care about game data links for player's team
    game_links = [link.strip('/') for link in game_links if 'gid' in link and team.lower() in link]

    # iterate through team's games for the day
    for gameID in game_links:
        # get the player's batter data file for this game
        data_url = game_day_url + gameID
        data_url += "/batters/{0}.xml".format(playerID)
        page = PQ(data_url)
        # just the at-bat events please
        atbats = page('atbats ab')

        # iterate through player's at-bats
        for index, event in enumerate(atbats):
            atbat = index+1
            # see if we've seen this at-bat
            rkey = "{0}-{1}-AB{2}".format(gameID, playerID, atbat)
            stored = r.get(rkey)

            # store results of new at-bats so we only
            # match against events we haven't seen
            if not stored:
                result = PQ(event).attr("event")
                match = result.lower() in [event.lower() for event in CONFIG['events_tracked']]
                r.set(rkey, result)
                
                # if we match, do a thing
                if match:
                    handle_match(result)
                else:
                    handle_miss(result)
    print 'Done with scrape.' 
开发者ID:ryanpitts,项目名称:ichiro3000,代码行数:49,代码来源:fetch.py


注:本文中的pyquery.PyQuery.lower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。