Update app.py
Browse files
app.py
CHANGED
@@ -127,15 +127,14 @@ 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 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
data = [dict(t) for t in {tuple(d.items()) for d in data}]
|
139 |
except Exception as e:
|
140 |
st.error(f"Exception during comment extraction: {e}")
|
141 |
driver.quit()
|
|
|
127 |
comments = driver.find_elements(By.CSS_SELECTOR, "#content #content-text")
|
128 |
user_id = 1
|
129 |
for comment in comments:
|
130 |
+
timestamp_elements = comment.find_elements(By.XPATH, './/a[@id="time"]') #Correct XPATH syntax.
|
131 |
+
timestamp = "Timestamp not found"
|
132 |
+
if timestamp_elements:
|
133 |
+
timestamp = timestamp_elements[0].text
|
134 |
+
data.append({"User ID": user_id, "Comment": comment.text, "comment_date": timestamp}
|
135 |
+
user_id += 1
|
136 |
+
data = [dict(t) for t in {tuple(d.items()) for d in data}]
|
137 |
+
|
|
|
138 |
except Exception as e:
|
139 |
st.error(f"Exception during comment extraction: {e}")
|
140 |
driver.quit()
|