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


Python PyQuery.val方法代码示例

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


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

示例1: get_settings

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import val [as 别名]
    def get_settings(self):
        req = requests.get("{}/@@maxui-settings".format(self.site_url), auth=self.auth)
        pq = PyQuery(req.content)
        inputs = pq("form input[type=hidden], form input[type=text]")

        settings = {}

        for inp in inputs:
            pqinput = PyQuery(inp)
            settings[pqinput.attr("name").split(".")[-1]] = pqinput.val()
        return settings
开发者ID:UPCnet,项目名称:gummanager.libs,代码行数:13,代码来源:_ulearn.py

示例2: press_form_button

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import val [as 别名]
def press_form_button(button_name):
    page = scc.current_page
    ok_(scc.current_page is not None, "there should be a current page")

    if scc.current_form_context is not None:
        # If we have a form context, search for the button within that form.
        form = scc.current_form_context
        form_action = form.attr('action')
        if not form_action: 
            form_action = scc.current_path
        form_method = form.attr('method')
        if not form_method: 
            form_method = 'post'

        field = form.find('input[value^="%s"]' % button_name)
        button_value = field.val()
        if len(field) == 0:
            field = form.find('button:contains("%s")' % button_name)
            button_value = field.text()
        if len(field) == 0:
            field = form.find('*[name="%s"]' % button_name)
            button_value = field.text()
        ok_(len(field) > 0, 'button "%s" should exist' % button_name)

        button_name = field.attr('name')
        scc.current_form[button_name] = button_value

    else:
        # If we have no form context, find the button and work up to the form.
        field = page('input[value^="%s"]' % button_name)
        button_value = field.val()
        if len(field) == 0:
            field = page('button:contains("%s")' % button_name)
            button_value = field.text()
        if len(field) == 0:
            field = page('*[name="%s"]' % button_name)
            button_value = field.text()
        ok_(len(field) > 0, 'button "%s" should exist' % button_name)

        button_name = field.attr('name')
        scc.current_form[button_name] = button_value

        form = field.parents('form:first')
        form_action = form.attr('action')
        if not form_action: 
            form_action = scc.current_path
        form_method = form.attr('method')
        if not form_method: 
            form_method = 'post'

    for field in form.find('input,textarea,select'):
        p_field = PyQuery(field)
        name, value = p_field.attr('name'), p_field.val()
        if value is None: value = ''
        if name not in scc.current_form:
            scc.current_form[name] = value

    if form_method.lower() == 'post':
        resp = scc.browser.post(form_action, scc.current_form, follow=True)
    else:
        resp = scc.browser.get(form_action, scc.current_form, follow=True)

    #eq_(200, resp.status_code)
    set_current_page(form_action, resp)
开发者ID:lmorchard,项目名称:badger,代码行数:66,代码来源:steps.py


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