本文整理汇总了Python中scraper.Scraper.fetch_booster_usage方法的典型用法代码示例。如果您正苦于以下问题:Python Scraper.fetch_booster_usage方法的具体用法?Python Scraper.fetch_booster_usage怎么用?Python Scraper.fetch_booster_usage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scraper.Scraper
的用法示例。
在下文中一共展示了Scraper.fetch_booster_usage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scrape
# 需要导入模块: from scraper import Scraper [as 别名]
# 或者: from scraper.Scraper import fetch_booster_usage [as 别名]
def scrape():
scraper = Scraper(**get_creds())
# Fetch usage info re: boosters.
le = UsageDataPoint(
time=datetime.datetime.utcnow(),
**scraper.fetch_booster_usage()
)
db_session.add(le)
yield le
# Fetch latest transactions and put these in the DB,
# but only if we don't already have them.
for transaction in scraper.fetch_most_recent_transactions():
existing = KoodoTransaction \
.query \
.filter_by(koodo_id=transaction['koodo_id']) \
.first()
if not existing:
kt = KoodoTransaction(**transaction)
db_session.add(kt)
yield kt
db_session.commit()