本文整理汇总了Python中models.Employee.tel方法的典型用法代码示例。如果您正苦于以下问题:Python Employee.tel方法的具体用法?Python Employee.tel怎么用?Python Employee.tel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Employee
的用法示例。
在下文中一共展示了Employee.tel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: profile_handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import tel [as 别名]
def profile_handler(doc, name, url, path):
filename = os.path.join(path, name + ".html")
employee = Employee(name=name, url=url)
# 只保存名称和个人主页,个人简历文件另存当前目录
soup = BeautifulSoup(doc, Config.SOUP_PARSER)
divs = soup.find_all(name="div", attrs={"id":"phy-main"}, limit=1)
if not divs or len(divs) == 0:
return employee
div = divs[0]
if not os.path.exists(filename):
with open(filename, 'wb') as fp:
content = div.prettify()
fp.write(content)
fp.close()
#email
email_div = soup.find_all(name='a',class_="phy-mail")
if email_div and len(email_div) != 0:
employee.email = email_div[0].get_text().strip()
te_div = soup.find_all(name='a',class_="phy-phone")
if te_div and len(te_div) != 0:
employee.tel = te_div[0].get_text().strip()
# 使用纯文本方式处理
lines = div.stripped_strings
# text=div.get_text(strip=True)
parser = ProfileParser(lines=lines,employee=employee,set_attr_hook=set_attr_hook)
return parser.parse()
示例2: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import tel [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 tel [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
示例4: handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import tel [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
示例5: profile_handler
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import tel [as 别名]
def profile_handler(doc, name, url, path):
filename = os.path.join(path, name + ".html")
email_image_filename = os.path.join(path, name + "_email.png")
tel_image_filename = os.path.join(path, name + "_tel.png")
employee = Employee(name=name, url=url)
# 只保存名称和个人主页,个人简历文件另存当前目录
soup = BeautifulSoup(doc, Config.SOUP_PARSER)
divs = soup.find_all(name="div", attrs={"id": "view_pannel"}, limit=1)
if not divs or len(divs) == 0:
div = soup
else:
div = divs[0]
if not os.path.exists(filename):
with open(filename, "wb") as fp:
content = div.prettify()
fp.write(content)
fp.close()
# email image
item_divs = div.find_all(name="div", attrs={"class": "item_list"})
ignores = []
for div in item_divs:
string = div.get_text()
if string and len(string) != 0:
if u"邮件" in string and len(employee.email) == 0:
employee.email = image2text(imageSrc(div), email_image_filename, "eng2")
print(employee.email)
ignores.append("email")
elif u"电话" in string and len(employee.tel) == 0:
employee.tel = image2text(imageSrc(div), tel_image_filename, "eng")
print(employee.tel)
ignores.append("tel")
# 使用纯文本方式处理
lines = div.stripped_strings
# text=div.get_text(strip=True)
parser = ProfileParser(
lines=lines, employee=employee, set_attr_hook=set_attr_hook, max_line=256, ignore=set(ignores)
)
return parser.parse()