Skip to content

Commit caf2dfc

Browse files
committed
test
1 parent 61cd556 commit caf2dfc

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/main.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# coding:utf-8
22
from selenium import webdriver
33
from selenium.common.exceptions import ElementNotVisibleException
4+
from selenium.common.exceptions import NoSuchElementException
45
from time import sleep
56
import codecs
67
from datetime import datetime
@@ -46,11 +47,20 @@
4647
q_and_a = []
4748
for qa in qa_elements:
4849
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))
50+
q = qa.find_element_by_class_name("streamItem_header").find_element_by_tag_name('h2').text
51+
except (ElementNotVisibleException, NoSuchElementException) as e:
52+
print("ElementNotVisible: {}".format(e))
5353
continue
54+
try:
55+
a = qa.find_element_by_class_name("streamItem_content").text
56+
except (ElementNotVisibleException, NoSuchElementException) as e:
57+
try:
58+
print("Check Answer card...")
59+
a = qa.find_element_by_class_name("asnwerCard_text").text
60+
except (ElementNotVisibleException, NoSuchElementException) as e:
61+
print("ElementNotVisible: {}".format(e))
62+
continue
63+
q_and_a.append((q, a))
5464

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

0 commit comments

Comments
 (0)