本文整理汇总了Python中models.Employee.name方法的典型用法代码示例。如果您正苦于以下问题:Python Employee.name方法的具体用法?Python Employee.name怎么用?Python Employee.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Employee
的用法示例。
在下文中一共展示了Employee.name方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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
示例2: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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
示例3: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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
示例4: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [as 别名]
def handler(tag):
employee = Employee()
name_divs = tag.find_all("div",class_="teacher-title")
if name_divs and len(name_divs) != 0:
employee.name = name_divs[0].get_text()
employee.name = ''.join(employee.name.split())
# 使用纯文本方式处理
lines = tag.stripped_strings
# text=div.get_text(strip=True)
parser = ProfileParser(lines=lines,employee=employee)
return parser.parse()
示例5: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [as 别名]
def handler(tag):
employee = Employee()
ass = tag.find_all('a',class_="orangea")
if ass and len(ass) != 0:
employee.name = ass[0].get_text()
employee.name = ''.join(employee.name.split())
employee.profile = ass[0]['href']
ass = tag.find_all('a',class_="black01")
if ass and len(ass) != 0:
lines = ass[0].stripped_strings
parser = ProfileParser(lines=lines,employee=employee)
employee = parser.parse()
return employee
示例6: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [as 别名]
def handler(tag):
employee = Employee(url=tag['href'])
# 刘全勇: 硕士生导师
string = ''.join(tag.get_text().split())
string_splits = string.split(u':')
if len(string_splits) == 1:
employee.name = string_splits[0]
elif len(string_splits) == 2:
employee.name = string_splits[0]
employee.title = string_splits[1]
else:
return None
print("name:"+employee.name )
return employee
示例7: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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
示例8: profile_handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [as 别名]
def profile_handler(doc,name,url,path):
# employee可用属性(url, name, email, tel, title, profile, research, departments,fax,addr):
symbols = {
u'Email:' :'email',
u'邮箱:' :'email',
u'电子邮件:' :'email',
u'电子邮箱:' :'email',
u'电话:' :'tel',
u'联系电话:' :'tel',
u'Tel:' :'tel',
u'办公电话:' :'tel',
u'传真:' :'fax',
u'URL:' :'url',
u'职称:' :'title'
}
employee = None
# 太乱了,只保存名称和个人主页,个人简历文件另存当前目录
soup = BeautifulSoup(doc, Config.SOUP_PARSER)
divs = soup.find_all(id="s2_right_con",limit=1)
filename = path+name+".html"
if not divs or len(divs) == 0:
return Employee(name=name,url=url)
div =divs[0]
with open(filename,'wb') as fp:
content = div.prettify()
fp.write(content)
fp.close()
employee = Employee()
# parse name
name_h4 = div.h4
if name_h4:
employee.name = name_h4.string.strip(' \t\n\r')
else:
print name_h4
for tag in div.children:
if not tag.string:
continue
text = tag.string.strip(' \t\n\r')
if len(text) == 0:
continue
for symbol,name in symbols.items():
idx = text.find(symbol)
if idx != -1:
idx += len(symbol)
value = text[idx:]
if hasattr(employee, name):
setattr(employee, name, value)
symbols
# print (name + ":" + value)
else:
print ("no attr %s in employee" % name)
break
return employee
示例9: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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
示例10: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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()
示例11: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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
示例12: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [as 别名]
def handler(tag):
symbols = set([u'首页',u'第一页',u'下一页',u'最后页 ',u'上一页',])
if not tag.string:
return None
name = tag.string.strip()
if name in symbols:
return None
employee = Employee(name=name, url=tag['href'])
# 根据预定的关键词推测身分
for keyword in PROFILE_TITLES:
idx = name.find(keyword)
if idx != -1:
employee.name = name[:idx]
employee.title = name[idx:]
break
return employee
示例13: create_employee_process
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [as 别名]
def create_employee_process():
employee = Employee()
employee.name = request.form['name']
employee.phone = request.form['phone']
employee.email = request.form['email']
employee.address = {
'street': request.form['street'],
'city': request.form['city'],
'state': request.form['state'],
'zipcode': request.form['zipcode'],
}
if employee.create_employee():
msg = Message()
employee.send_email(mail, msg, app)
return 'Success'
else:
raise Exception
示例14: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import name [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