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


Python Ghost.create_page方法代码示例

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


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

示例1: test1

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import create_page [as 别名]
def test1():
    url = "http://www.ebay.com/"
    gh = Ghost()
    # We create a new page
    page, page_name = gh.create_page()
    # We load the main page of ebay
    page_resource = page.open(url, wait_onload_event=True)
    # Full the main bar and click on the search button
    page.set_field_value("#gh-ac", "plane")
    page.click("#gh-btn")
    # Wait for the next page
    page.wait_for_selector("#e1-15")
    # Save the image of the screen
    page.capture_to("plane.png")
开发者ID:zhibzeng,项目名称:PythonCode,代码行数:16,代码来源:fibo.py

示例2: Ghost

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import create_page [as 别名]
from ghost import Ghost

url = "http://news.ycombinator.com/"
# We enable the cache and set the maximun size to 10 MB
# We don't want to load images and load css or js files
gh = Ghost(cache_size=10)

# We create a new page
page, page_name = gh.create_page(download_images=False,
        prevent_download=["css", "js"])

# wait_onload_event will tell to Ghost to leave the open method
# when the On Ready event on the web page has been fired
page_resource = page.open(url, wait_onload_event=False)

# We retrive the links from the web page
links = page.evaluate("""
                        var links = document.querySelectorAll("a");
                        var listRet = [];
                        for (var i=0; i<links.length; i++){
                            listRet.push(links[i].href);
                        }
                        listRet;
                    """)
# Print the links
for l in links:
    print l
开发者ID:a1939228,项目名称:Ghost.py,代码行数:29,代码来源:fast_open.py

示例3: Ghost

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import create_page [as 别名]
from ghost import Ghost

# Creates a Ghost instance telling to don't download css files and images
gh = Ghost()
gpage, name = gh.create_page(download_images=True, prevent_download=["css"])

# Open google
gpage.open("http://www.google.com")

# Saves an image of the screen
gpage.capture_to("/tmp/selective_download.png")

开发者ID:a1939228,项目名称:Ghost.py,代码行数:13,代码来源:selective_download.py

示例4: Ghost

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import create_page [as 别名]
from ghost import Ghost
import time

# 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")
开发者ID:a1939228,项目名称:Ghost.py,代码行数:33,代码来源:multiple_tabs_concurrent.py


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