-
Notifications
You must be signed in to change notification settings - Fork 0
/
wordart.py
53 lines (37 loc) · 1.92 KB
/
wordart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# coding:utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
import tokenization
txt_file = "raw.txt"
input_txt = tokenization.tokenize(txt_file)
# input_txt = "哈哈哈"
driver=webdriver.Safari()
driver.maximize_window()
driver.get(r'https://wordart.com/create')
wait = WebDriverWait(driver, 10)
time.sleep(1) # Problem here
wait.until(EC.presence_of_element_located((By.XPATH,"//*[@id='root']/div/div[2]/div[1]/div/div[3]")))
fonts = driver.find_element_by_xpath("//*[@id='root']/div/div[2]/div[1]/div/div[3]")
fonts.click()
# wait.until(EC.presence_of_element_located((By.XPATH,"//*[@id='root']/div/div[2]/div[1]/div/div[3]/div[2]/div/ul/li[38]/div[1]/img")))
filter = driver.find_element_by_xpath("//*[@id='root']/div/div[2]/div[1]/div/div[3]/div[2]/div/div/input")
filter.send_keys("chinese")
chinese_fonts = driver.find_element_by_xpath("//*[@id='root']/div/div[2]/div[1]/div/div[3]/div[2]/div/ul/li[38]/div[1]")
chinese_fonts.click()
words = driver.find_element_by_xpath("//*[@id='root']/div/div[2]/div[1]/div/div[1]/div[1]")
words.click()
import_button = driver.find_element_by_xpath("/html/body/div/div/div/div//div/div/div/div/span/button[1]")
import_button.click()
import_area = driver.find_element_by_xpath("/html/body/div/div/div/div//div/div/div/textarea[1]")
import_area.send_keys(unicode(input_txt,'utf-8'))
import_words = driver.find_element_by_xpath("/html/body/div/div/div/div//div/div/button[@type='button'][@class='btn btn-dark']")
import_words.click()
# wait.until(EC.presence_of_element_located((By.XPATH,"//*[@id='root']/div/div[2]/div[2]/div[1]/button[1]")))
# time.sleep(3)
visual = driver.find_element_by_xpath("//*[@id='root']/div/div[2]/div[2]/div[1]/button[1]")
visual.send_keys(Keys.ENTER)
# driver.quit()