update: using nameparser
This commit is contained in:
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
@@ -14,6 +14,7 @@ from selenium.webdriver.remote.webelement import WebElement
|
||||
|
||||
from tkinter import Tk, filedialog
|
||||
from datetime import datetime, timedelta
|
||||
from nameparser import HumanName
|
||||
|
||||
parser = argparse.ArgumentParser(description="邮件批量发送脚本")
|
||||
parser.add_argument('input', nargs='?')
|
||||
@@ -231,9 +232,10 @@ def main():
|
||||
action.send_keys(hello)
|
||||
|
||||
if name is not None and (name := str(name).strip()) and not contains_non_latin_alphabet(name):
|
||||
parts = name.title().split()
|
||||
firstname = parts[0] if len(parts) == 1 or (len(parts[0]) > 3 and '.' not in parts[0]) else ' '.join([parts[0], parts[1]])
|
||||
action.send_keys(Keys.SPACE).send_keys(firstname)
|
||||
parts = HumanName(name)
|
||||
parts.capitalize()
|
||||
person = ' '.join(filter(None, [parts.title, parts.first or parts.middle or parts.last]))
|
||||
action.send_keys(Keys.SPACE).send_keys(person)
|
||||
|
||||
action.send_keys(',')
|
||||
action.perform()
|
||||
|
||||
Reference in New Issue
Block a user