當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。