Update app.py
Browse files
app.py
CHANGED
@@ -127,8 +127,11 @@ if st.button("Sentiment Analysis", type="secondary"):
|
|
127 |
comments = driver.find_elements(By.CSS_SELECTOR, "#content #content-text")
|
128 |
user_id = 1
|
129 |
for comment in comments:
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
132 |
data.append({"User ID": user_id, "Comment": comment.text, "comment_date": timestamp})
|
133 |
user_id += 1
|
134 |
data = [dict(t) for t in {tuple(d.items()) for d in data}]
|
|
|
127 |
comments = driver.find_elements(By.CSS_SELECTOR, "#content #content-text")
|
128 |
user_id = 1
|
129 |
for comment in comments:
|
130 |
+
try:
|
131 |
+
timestamp_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'div.author-info > time')))
|
132 |
+
timestamp = timestamp_element.text
|
133 |
+
except TimeoutException:
|
134 |
+
timestamp = None # Handle the case where the timestamp element isn't found
|
135 |
data.append({"User ID": user_id, "Comment": comment.text, "comment_date": timestamp})
|
136 |
user_id += 1
|
137 |
data = [dict(t) for t in {tuple(d.items()) for d in data}]
|