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


Python Ghost.wait_timeout方法代码示例

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


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

示例1: snap

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import wait_timeout [as 别名]
def snap(conn, url, cookie_name, cookie_value, width, height, loaded, hides, selector):
    """Handle all the work of taking the page snapshot.

    The first parameter is a connection object for a `multiprocessing.Pipe`
    that we use to send back the file name written to. The remaining parameters
    are `multiprocessing.Value`s.
    
    """
    ghost = None
    try:
        ghost = Ghost(viewport_size=(width.value, height.value))
        ghost.wait_timeout = 20

        headers = {}
        if cookie_name.value and cookie_value.value:
            headers = {
                'Cookie': str('%s=%s' % (cookie_name.value, cookie_value.value)),
            }

        ghost.open(url.value, headers=headers)

        if loaded.value:
            try:
                ghost.wait_for_selector('%s' % loaded.value)
            except:
                # if the selector never appears, we don't care
                pass

        selectors = hides.value.split(',')
        if len(selectors):
            hide_js = r'''
                if (jQuery) {
                    $(document).ready(function() {
                        %s
                    });
                }
            ''' % '\n'.join([r"$('%s').hide();" % sel for sel in selectors])
            ghost.evaluate(hide_js)

        handle, file_path = mkstemp(prefix='ansel_snap', suffix='.png')
        ghost.capture_to(file_path, selector=selector.value)

        conn.send(file_path)
    finally:
        del ghost
        conn.close()
开发者ID:Maplecroft,项目名称:Ansel,代码行数:48,代码来源:utils.py

示例2: heroku

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import wait_timeout [as 别名]
def heroku(api_key, year, month):
    ghost = None

    file_path = '/tmp/heroku_invoice_%d-%d.png' % (year, month)
    if os.path.exists(file_path):
        os.remove(file_path)

    # TODO: make dimensions configurable? Automatic (is that possible?)?
    ghost = Ghost(viewport_size=(1000, 1600))
    ghost.wait_timeout = 20

    ghost.open('https://id.heroku.com/login')
    ghost.fill("form", dict(email="", password=api_key))
    ghost.fire_on("form", "submit", expect_loading=True)
    ghost.open('https://dashboard.heroku.com/invoices/%s/%s' % (year, month))

    ghost.capture_to(file_path)

    return file_path
开发者ID:jimr,项目名称:Kanedama,代码行数:21,代码来源:kanedama.py


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