File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 11# coding:utf-8
22from selenium import webdriver
3- # from selenium.common.exceptions import ElementNotVisibleException
3+ from selenium .common .exceptions import ElementNotVisibleException
44from time import sleep
55import codecs
66from datetime import datetime
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 :
You can’t perform that action at this time.
0 commit comments