zoukankan      html  css  js  c++  java
  • BeautifulSoup解析本地文件

    import requests
    from bs4 import BeautifulSoup
    
    apex_class = ''
    apex_trigger = ''
    custome_object = ''
    profile = ''
    others = ''
    path = '/Users/aaa/Downloads/aaa.htm'
    htmlfile = open(path, 'r')
    
    htmlhandle = htmlfile.read()
    soup = BeautifulSoup(htmlhandle, "lxml") #soup = BeautifulSoup(htmlhandle, "html.parser")
    titles = soup.find_all("a", class_="link-gray-dark")
    for title in titles:
        if 'src' in title.text:
            if '.cls' in title.text:
                apex_class += '
    '+title.text
            elif '.trigger' in title.text:
                apex_trigger += '
    '+title.text
            elif '.object' in title.text:
                custome_object += '
    '+title.text
            elif '.profile' in title.text:
                profile += '
    '+title.text
            else:
                others += '
    '+title.text
                
    print ('apex_class:
    '+apex_class);
    print ('apex_trigger:
    '+apex_trigger);
    print ('custome_object:
    '+custome_object);
    print ('profile:
    '+profile);
    print ('others:
    '+others);
  • 相关阅读:
    tip
    tip
    paper clip 使用
    这个菜单有点cool
    jqueryoptiontree plugin introduce by frederick.mao
    ruby语法不理解
    近来心得,心不可太贪,见好就收
    XPCOM的有关链接
    rails router
    rails3高端observer模式
  • 原文地址:https://www.cnblogs.com/iwangzheng/p/13389698.html
Copyright © 2011-2022 走看看