本文整理汇总了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)
示例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.'