-
Notifications
You must be signed in to change notification settings - Fork 0
/
fc.py
60 lines (38 loc) · 1.45 KB
/
fc.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
53
54
from bs4 import BeautifulSoup
import requests
import os,re,time
from selenium import webdriver
class Word(object):
def __init__(self):
self.driver = webdriver.Chrome()
def start(self,text):
# PhantomJS
url = 'http://language.tiu.ac.jp/'
self.driver.get(url)
time.sleep(3)
aa = self.driver.page_source
self.driver.find_element_by_css_selector(
"body > center > form > table > tbody > tr > td:nth-child(1) > table > tbody > tr:nth-child(2) > td > textarea").send_keys(
text)
time.sleep(3)
self.driver.find_element_by_css_selector(
"body > center > form > table > tbody > tr > td:nth-child(1) > table > tbody > tr:nth-child(3) > td > input:nth-child(1)").click()
time.sleep(3)
self.driver.switch_to_window(self.driver.window_handles[1])
time.sleep(12)
self.driver.switch_to.frame("dic")
soup = BeautifulSoup(self.driver.page_source, 'lxml')
time.sleep(12)
select1 = "#overflowbox font[size=3]"
a1 = [x.get_text() for x in soup.select(select1)]
select2 = "#overflowbox > font[size=2]"
a2 = []
for x in soup.find_all(size="3"):
a2.append(x.next_sibling.get_text())
li = []
for aa1, aa2 in zip(a1, a2):
# print(aa1 + ': ' + aa2)
li.append(aa1 + ': ' + aa2)
print(li)
time.sleep(12)
return li