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


Python html._nons方法代码示例

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


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

示例1: _takes_multiple

# 需要导入模块: from lxml import html [as 别名]
# 或者: from lxml.html import _nons [as 别名]
def _takes_multiple(input):
    if _nons(input.tag) == 'select' and input.get('multiple'):
        # FIXME: multiple="0"?
        return True
    type = input.get('type', '').lower()
    if type in ('radio', 'checkbox'):
        return True
    return False 
开发者ID:JFox,项目名称:aws-lambda-lxml,代码行数:10,代码来源:formfill.py

示例2: _fill_multiple

# 需要导入模块: from lxml import html [as 别名]
# 或者: from lxml.html import _nons [as 别名]
def _fill_multiple(input, value):
    type = input.get('type', '').lower()
    if type == 'checkbox':
        v = input.get('value')
        if v is None:
            if not value:
                result = False
            else:
                result = value[0]
                if isinstance(value, basestring):
                    # The only valid "on" value for an unnamed checkbox is 'on'
                    result = result == 'on'
            _check(input, result)
        else:
            _check(input, v in value)
    elif type == 'radio':
        v = input.get('value')
        _check(input, v in value)
    else:
        assert _nons(input.tag) == 'select'
        for option in _options_xpath(input):
            v = option.get('value')
            if v is None:
                # This seems to be the default, at least on IE
                # FIXME: but I'm not sure
                v = option.text_content()
            _select(option, v in value) 
开发者ID:JFox,项目名称:aws-lambda-lxml,代码行数:29,代码来源:formfill.py

示例3: _fill_single

# 需要导入模块: from lxml import html [as 别名]
# 或者: from lxml.html import _nons [as 别名]
def _fill_single(input, value):
    if _nons(input.tag) == 'textarea':
        input.text = value
    else:
        input.set('value', value) 
开发者ID:JFox,项目名称:aws-lambda-lxml,代码行数:7,代码来源:formfill.py

示例4: _insert_error

# 需要导入模块: from lxml import html [as 别名]
# 或者: from lxml.html import _nons [as 别名]
def _insert_error(el, error, error_class, error_creator):
    if _nons(el.tag) in defs.empty_tags or _nons(el.tag) == 'textarea':
        is_block = False
    else:
        is_block = True
    if _nons(el.tag) != 'form' and error_class:
        _add_class(el, error_class)
    if el.get('id'):
        labels = _label_for_xpath(el, for_id=el.get('id'))
        if labels:
            for label in labels:
                _add_class(label, error_class)
    error_creator(el, is_block, error) 
开发者ID:JFox,项目名称:aws-lambda-lxml,代码行数:15,代码来源:formfill.py

示例5: form_values

# 需要导入模块: from lxml import html [as 别名]
# 或者: from lxml.html import _nons [as 别名]
def form_values(self):
    """
    Return a list of tuples of the field values for the form.
    This is suitable to be passed to ``urllib.urlencode()``.
    """
    results = []
    for el in self.inputs:
        name = el.name
        if not name:
            continue
        tag = _nons(el.tag)
        if tag == 'textarea':
            results.append((name, el.value))
        elif tag == 'select':
            value = el.value
            if el.multiple:
                for v in value:
                    results.append((name, v))
            elif value is not None:
                results.append((name, el.value))
        else:
            assert tag == 'input', (
                "Unexpected tag: %r" % el)
            if el.checkable and not el.checked:
                continue
            if el.type in ('image', 'reset'):
                continue
            value = el.value
            if value is not None:
                results.append((name, el.value))
    return results 
开发者ID:eBay,项目名称:wextracto,代码行数:33,代码来源:form.py


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