Skip to content

Commit 61cd556

Browse files
committed
test
1 parent 67bd962 commit 61cd556

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding:utf-8
22
from selenium import webdriver
3-
# from selenium.common.exceptions import ElementNotVisibleException
3+
from selenium.common.exceptions import ElementNotVisibleException
44
from time import sleep
55
import codecs
66
from datetime import datetime
@@ -40,8 +40,17 @@
4040

4141
print("QA content: {}".format(len(qa_elements)))
4242

43-
q_and_a = [(qa.find_element_by_class_name("streamItem_header").find_element_by_tag_name('h2').text,
44-
qa.find_element_by_class_name("streamItem_content").text) for qa in qa_elements]
43+
# q_and_a = [(qa.find_element_by_class_name("streamItem_header").find_element_by_tag_name('h2').text,
44+
# qa.find_element_by_class_name("streamItem_content").text) for qa in qa_elements]
45+
46+
q_and_a = []
47+
for qa in qa_elements:
48+
try:
49+
q_and_a.append((qa.find_element_by_class_name("streamItem_header").find_element_by_tag_name('h2').text,
50+
qa.find_element_by_class_name("streamItem_content").text))
51+
except ElementNotVisibleException as e:
52+
print("ElementNotVisible: Skip QA: {}".format(e))
53+
continue
4554

4655
with codecs.open("data/askfm_data/" + face + ".txt", "w", "utf-8") as f:
4756
for q, a in q_and_a:

0 commit comments

Comments
 (0)