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


Python Employee.url方法代码示例

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


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

示例1: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    tds = tag.find_all(name='td')
    if not tds or len(tds) != 5:
        return None
    
    name = tds[0].get_text()
    if not name or len(name) == 0:
        return None

    employee = Employee()
    employee.name = ''.join(name.split())
    if employee.name == u'姓名':
        return None

    ass = tag.find_all('a')
    if ass:
        employee.url = ass[0]['href']

    title = tds[3].get_text()
    if title and len(title) != 0:
        title = ''.join(title.split())
        title = title.replace(',',',')
        employee.title = title
        print title

    research = tds[4].get_text()
    if research and len(research) != 0:
        employee.research = research.strip()
        employee.research = employee.research.replace(',',',')
    
    return employee
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:33,代码来源:MyHandler.py

示例2: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    tds = tag.find_all(name='td')
    if not tds:
        print("len(tds) == 0")
        return None

    employee = Employee()
    if len(tds) < 4:
        print("len(tds) = %d"%(len(tds)))
        return None

    
    name_tag = tds[0]
    employee.name = name_tag.get_text()
    employee.name = employee.name.strip()
    if employee.name == u'姓名':
        return None

    ass = name_tag.find_all('a')
    if ass and len(ass) != 0:
        employee.url = ass[0]['href']
    
    employee.title = tds[2].get_text().strip()
    employee.departments = tds[3].get_text().strip()

    return employee
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:28,代码来源:MyHandler.py

示例3: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    tds = tag.find_all(name='td')
    if not tds:
        print("len(tds) == 0")
        return None

    employee = Employee()
    if len(tds) < 5:
        print("len(tds) = %d"%(len(tds)))
        return None

    name_tag = None
    name_tag_idx = 0
    if len(tds) == 5:
        name_tag_idx = 0
        name_tag = tds[name_tag_idx]
    elif len(tds) > 5:
        name_tag_idx = 1
        name_tag = tds[name_tag_idx]

    employee.name = name_tag.get_text()
    employee.name = employee.name.strip()
    if employee.name == u'姓名':
        return None
    ass = name_tag.find_all('a')
    if ass and len(ass) != 0:
        employee.url = ass[0]['href']
    
    employee.title = tds[name_tag_idx+1].get_text().strip()
    employee.email = tds[name_tag_idx+2].get_text().strip()
    employee.tel   = tds[name_tag_idx+3].get_text().strip()

    return employee
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:35,代码来源:MyHandler.py

示例4: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    tds = tag.find_all("td")
    if not tds or len(tds) != 4:
        return None
    employee = Employee()
    ass = tag.find_all('a')
    if ass and len(ass) != 0:
        employee.url = ass[0]['href']
    employee.name = tds[0].get_text().strip()
    employee.name = ''.join(employee.name.split())

    title = tds[1].get_text()
    if title and len(title) != 0:
        employee.title = ''.join(title.split())

    email = tds[3].get_text()
    if email and len(email) != 0:
        employee.email = ''.join(email.split())


    tel = tds[2].get_text()
    if tel and len(tel) != 0:
        employee.tel = ''.join(tel.split())

    return employee
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:27,代码来源:MyHandler.py

示例5: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    employee = Employee()
    names = tag.get_text()
    names = ''.join(names.split())
    names = names.replace(')','')
    names = names.replace(')','')
    names = names.replace('(','(')
    names = names.split('(')
    employee.name = names[0]
    if len(names) >= 2:
        employee.title = names[1]
    employee.url = tag['href']
    print employee.name, employee.title
    return employee
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:16,代码来源:MyHandler.py

示例6: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    employee = Employee()

    lines = tag.stripped_strings

    ass = tag.find_all(name="a", attrs={"class": "dt_text_tit"})
    if not ass or len(ass) == 0:
        # first line is the name
        for count, line in enumerate(lines):
            employee.name = line
            break
    else:
        employee.name = ass[0].string
        employee.profile = ass[0]["href"]
        employee.url = employee.profile

    parser = ProfileParser(lines=lines, employee=employee)
    employee = parser.parse()
    return employee
开发者ID:yixiaoyang,项目名称:EduParser,代码行数:21,代码来源:MyHandler.py

示例7: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    
    name_spans = tag.find_all(class_="handle")
    if not name_spans or len(name_spans) == 0:
        return None
    
    # js <span class="handle" onclick="toCardDetailAction('10c07e70-3fb6-42af-aa26-bfab26b6ce0406');" style="color:#2084D2;font-size: 16px;">艾明晶</span>
    
    employee = Employee()
    employee.name = name_spans[0].get_text()
    employee.name = ''.join(employee.name.split())
    
    card_id = name_spans[0]['onclick'][len('toCardDetailAction(\''):-3]
    employee.url = 'http://scse.buaa.edu.cn/buaa-css-web/toCardDetailAction.action?firstSelId=CARD_TMPL_OF_FIRST_NAVI_CN%20&%20secondSelId=CARD_TMPL_OF_ALL_TEACHER_CN%20&cardId='+card_id
    print ("card_id=[%s]"%card_id)

    
    lines = tag.stripped_strings
    parser = ProfileParser(lines=lines,employee=employee)
    return parser.parse()
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:22,代码来源:MyHandler.py

示例8: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    name_symbol = u'姓名'
    tds = tag.find_all('td')
    
    if len(tds) != 7:
        return None
    if tds[0].get_text().strip() == name_symbol:
        return None
    employee = Employee()
    
    ass = tds[0].find_all('a')
    if len(ass) != 0:
        employee.url = ass[0]['href']
    employee.name = tds[0].get_text().strip()
    employee.email = tds[2].get_text().strip()
    employee.title = tds[3].get_text().strip()
    employee.research = tds[6].get_text().strip()
    employee.research.replace('\n','.')
    print employee.name,employee.email,employee.title
    return employee
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:22,代码来源:MyHandler.py

示例9: handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def handler(tag):
    dd_tables = {
        "Email":"email",
        "Phone":"tel",
        "Homepage":"profile",
        'Math Fields':'research'
    }
    lis = tag.find_all('li')
    if len(lis) < 4:
        return None
    employee = Employee()
    
    pre_len = len(u'职务:')
    
    employee.name = lis[0].get_text()
    employee.profile = lis[0].a['href']
    employee.url = employee.url or employee.profile
    if not employee.name:
        employee.name = employee.name[pre_len:]
        employee.name = ''.join(employee.name.split()) 
  
    employee.title = lis[1].get_text()
    if employee.title:
        employee.title =  employee.title[pre_len:]
        employee.title = ''.join(employee.title.split()) 
        
    employee.tel = lis[2].get_text()
    if employee.tel:
        employee.tel =  employee.tel[pre_len:]
        employee.tel = ''.join(employee.tel.split()) 
    
    employee.email = lis[3].get_text()
    if employee.email:
        employee.email =  employee.email[pre_len:]
        employee.email = ''.join(employee.email.split()) 

    print("name:"+employee.name+",email:"+employee.email)
    return employee
开发者ID:Jumbo-WJB,项目名称:EduParser,代码行数:40,代码来源:MyHandler.py

示例10: profile_handler

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import url [as 别名]
def profile_handler(doc,name,url,path):
    # employee可用属性(url, name, email, tel, title, profile, research, departments,fax,addr):
    symbols = {
        'email': u'电子邮件:',
        'tel': u'办公电话:',
        'addr': u'办公地址:',
        'research':u'研究方向:'
    }
    employee = None

    soup = BeautifulSoup(doc, Config.SOUP_PARSER)
    divs = soup.find_all("td",attrs={"valign":"top"},limit=1)
    if not divs or len(divs) == 0:
        return employee

    div = divs[0]
    employee = Employee()
    
    # save file
    filename = path+name+".html"
    with open(filename,'wb') as fp:
        content = div.prettify()
        fp.write(content)
        fp.close()
        
    # parse name
    name_h3 = div.h3
    if name_h3:
        employee.name = name_h3.string.strip(' \t\n\r')
    else:
        print name_h3
    # parse title
    dls = soup.dl
    if dls and len(dls) >= 1:
        print dls
        if dls.dt:
            employee.title = dls.dt.string
        # parse everything
        for tag in dls.children:
            if not tag.string:
                continue
            text = tag.string.strip(' \t\n\r')
            if len(text) == 0:
                continue
            for name, symbol in symbols.items():
                idx = text.find(symbol)
                if idx != -1:
                    idx += len(symbol)
                    value = text[idx:]
                    if hasattr(employee, name):
                        setattr(employee, name, value)
                        # print (name + ":" + value)
                    else:
                        print ("no attr %s in employee" % name)
                    break
    # parse profile
    teachcontent = soup.find_all("div",class_="teachcontent",limit=1)
    if len(teachcontent) != 0:
        content = teachcontent[0]
        link= content.a
        if link:
            employee.url = link['href']

    return employee
开发者ID:yixiaoyang,项目名称:pyScripts,代码行数:66,代码来源:MyHandler.py


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