本文整理汇总了Python中stage.Stage.put方法的典型用法代码示例。如果您正苦于以下问题:Python Stage.put方法的具体用法?Python Stage.put怎么用?Python Stage.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stage.Stage
的用法示例。
在下文中一共展示了Stage.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_tour_data
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import put [as 别名]
def generate_tour_data():
urlfetch.set_default_fetch_deadline(45)
data_order=["date","stage-icons","stage-link","name","stage-winner","stage-leader","km"]
page = urllib2.urlopen("http://www.procyclingstats.com/race/Tour_de_France_2015-stages")
soup = BeautifulSoup(page, "html.parser")
tabulka = soup.find("table", {"id" : "list5"})
data={}
stage_count=0
for row in tabulka.findAll('tr'):
col = row.findAll('td')
data={}
images=[]
count=1
for td in col:
#Looking for the date
if(td.string):
if(count==1):
data["date"]=td.string
count+=1
#Do we have icons?
imgs=td.findAll('img')
if imgs:
for img in imgs:
images.append(img["src"])
data["stage_icons"]=images
#Names for the winner and the leader
links = td.findAll('a')
for link in links:
if count==2:
if(link.string):
data["name"]=link.string
data["stage-link"]="http://www.procyclingstats.com/"+link['href']
else:
data["stage-link"]=""
if count==3:
if(link.string):
data["stage-winner"]=link.string
else:
data["stage-winner"]=""
if count==4:
if(link.string):
try:
km = float(link.string)
data["km"]=link.string
data["stage-leader"]=""
except ValueError:
data["stage-leader"]=link.string
else:
data["stage-leader"]=""
if count==5:
if(link.string):
data["km"]=link.string
else:
data["km"]=""
count+=1
if data:
stage_count+=1
data["stage"]=str(stage_count)
if(stage_count<22):
stage = Stage(id=stage_count,data=json.dumps(data))
stage.put()