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 tkinter import Tk, filedialog
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from nameparser import HumanName
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="邮件批量发送脚本")
|
parser = argparse.ArgumentParser(description="邮件批量发送脚本")
|
||||||
parser.add_argument('input', nargs='?')
|
parser.add_argument('input', nargs='?')
|
||||||
@@ -231,9 +232,10 @@ def main():
|
|||||||
action.send_keys(hello)
|
action.send_keys(hello)
|
||||||
|
|
||||||
if name is not None and (name := str(name).strip()) and not contains_non_latin_alphabet(name):
|
if name is not None and (name := str(name).strip()) and not contains_non_latin_alphabet(name):
|
||||||
parts = name.title().split()
|
parts = HumanName(name)
|
||||||
firstname = parts[0] if len(parts) == 1 or (len(parts[0]) > 3 and '.' not in parts[0]) else ' '.join([parts[0], parts[1]])
|
parts.capitalize()
|
||||||
action.send_keys(Keys.SPACE).send_keys(firstname)
|
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.send_keys(',')
|
||||||
action.perform()
|
action.perform()
|
||||||
|
|||||||
Reference in New Issue
Block a user