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


Python bs4.CData方法代码示例

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


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

示例1: check_companies

# 需要导入模块: import bs4 [as 别名]
# 或者: from bs4 import CData [as 别名]
def check_companies(session, sessionData):
    r = session.get(ERP_COMPANIES_URL, **req_args)

    companies_list = bs(r.text, 'html.parser')
    companies = []
    for row in companies_list.find_all('row'):
        company = {}
        cds = filter(lambda x: isinstance(x, CData), row.find_all(text=True))

        a = bs(cds[0].string, 'html.parser').find_all('a')[0]
        company['name'], company['name_link'] = a.attrs['title'], a.attrs['onclick']

        a = bs(cds[3].string, 'html.parser').find_all('a')[0]
        company['job'], company['job_link'] = a.attrs['title'], a.attrs['onclick']

        a = bs(cds[7].string, 'html.parser').find_all('a')[0]
        company['description_link'] = a.attrs['onclick']

        company['start_date'], company['end_date'] = cds[9], cds[10]
        companies.append(company)

    handle_companies_diff(companies) 
开发者ID:metakgp,项目名称:mftp,代码行数:24,代码来源:update.py

示例2: is_cdata

# 需要导入模块: import bs4 [as 别名]
# 或者: from bs4 import CData [as 别名]
def is_cdata(obj):
        """Is CDATA."""
        return isinstance(obj, bs4.CData) 
开发者ID:facelessuser,项目名称:soupsieve,代码行数:5,代码来源:css_match.py

示例3: is_special_string

# 需要导入模块: import bs4 [as 别名]
# 或者: from bs4 import CData [as 别名]
def is_special_string(obj):
        """Is special string."""
        return isinstance(obj, (bs4.Comment, bs4.Declaration, bs4.CData, bs4.ProcessingInstruction, bs4.Doctype)) 
开发者ID:facelessuser,项目名称:soupsieve,代码行数:5,代码来源:css_match.py

示例4: is_special_string

# 需要导入模块: import bs4 [as 别名]
# 或者: from bs4 import CData [as 别名]
def is_special_string(obj):
        """Is special string."""

        import bs4
        return isinstance(obj, (bs4.Comment, bs4.Declaration, bs4.CData, bs4.ProcessingInstruction)) 
开发者ID:tvaddonsco,项目名称:plugin.git.browser,代码行数:7,代码来源:css_match.py

示例5: is_cdata

# 需要导入模块: import bs4 [as 别名]
# 或者: from bs4 import CData [as 别名]
def is_cdata(obj):
        """Is CDATA."""

        import bs4
        return isinstance(obj, bs4.CData) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:7,代码来源:css_match.py

示例6: is_special_string

# 需要导入模块: import bs4 [as 别名]
# 或者: from bs4 import CData [as 别名]
def is_special_string(obj):
        """Is special string."""

        import bs4
        return isinstance(obj, (bs4.Comment, bs4.Declaration, bs4.CData, bs4.ProcessingInstruction, bs4.Doctype)) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:7,代码来源:css_match.py

示例7: check_notices

# 需要导入模块: import bs4 [as 别名]
# 或者: from bs4 import CData [as 别名]
def check_notices(session, sessionData):
    r = session.get(ERP_NOTICEBOARD_URL, **req_args)
    r = session.get(ERP_NOTICES_URL, **req_args)

    print "ERP and TNP login completed!"

    notices_list = bs(r.text, 'html.parser')

    print "Total number of notices fetched: %d" % len(notices_list.find_all('row'))

    notices = []
    # Only check the first 50 notices
    for row in notices_list.find_all('row')[:NUM_NOTICES_DIFFED]:
        notice = {}

        cds = filter(lambda x: isinstance(x, CData), row.find_all(text=True))

        notice['subject'] = cds[2].string
        notice['company'] = cds[3].string

        a = bs(cds[4].string, 'html.parser').find_all('a')[0]
        try :
            m = re.search(r'ViewNotice\("(.+?)","(.+?)"\)', a.attrs['onclick'])
        except KeyError :
            print("Poorly formatted notice found")
            continue
        year, id_ = m.group(1), m.group(2)
        content = bs(session.get(ERP_NOTICE_CONTENT_URL % (year, id_)).text, 'html.parser')
        content_div = bs.find_all(content, 'div', {'id': 'printableArea'})[0]
        notice['text'] = content_div.decode_contents(formatter='html')
        notice['time'] = cds[6].string

        a = bs(cds[7].string, 'html.parser').find_all('a')[0]
        if a.attrs['title'] == 'Download':
            onclick = a.attrs['onclick']
            m = re.search(r'TPNotice\("(.+)"\)', onclick)
            notice['attachment_url'] = ERP_ATTACHMENT_URL + m.group(1)
            r = session.get(notice['attachment_url'], stream=True)
            r.raw.decode_content = True
            hash_ = hashlib.md5()
            notice['attachment_raw'] = b""
            for chunk in r.iter_content(4096):
                notice['attachment_raw'] += chunk
                hash_.update(chunk)
            notice['attachment_md5'] = hash_.hexdigest()

        notices.append(notice)

    handle_notices_diff(notices) 
开发者ID:metakgp,项目名称:mftp,代码行数:51,代码来源:update.py


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