本文整理汇总了Python中ghost.Ghost.process_events方法的典型用法代码示例。如果您正苦于以下问题:Python Ghost.process_events方法的具体用法?Python Ghost.process_events怎么用?Python Ghost.process_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ghost.Ghost
的用法示例。
在下文中一共展示了Ghost.process_events方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Ghost
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import process_events [as 别名]
# Creates a Ghost instance telling to share cache and don't share cookies
gh = Ghost(share_cache=True, share_cookies=False)
page1, name = gh.create_page()
page2, name = gh.create_page()
# Open google
page1.open("http://www.google.com", wait_for_loading=False)
# Open Hacker News
page2.open("http://news.ycombinator.com/", wait_for_loading=False)
# At this point ghost it's rendering the two pages at the same time. Now we
# need to check if the pages are loaded.
while page1.get_loaded_page() is None:
page_resource = page1.get_loaded_page()
gh.process_events()
time.sleep(0.01)
# Saves an image of the screen 1
page1.capture_to("/tmp/tab1.png")
print "open /tmp/tab1.png"
#Or we can use wait_for_page_loaded() instead
page2.wait_for_page_loaded()
# Saves an image of the screen 2
page2.capture_to("/tmp/tab2.png")
print "open /tmp/tab2.png"
# Then we remove the tabs from ghost instance