nlpblogs commited on
Commit
84fcf4e
·
verified ·
1 Parent(s): 6f7530c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -125,15 +125,13 @@ if st.button("Sentiment Analysis", type="secondary"):
125
  try:
126
  wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#contents #contents")))
127
  comments = driver.find_elements(By.CSS_SELECTOR, "#content #content-text")
128
-
129
-
130
-
131
  user_id = 1
132
- for comment in comments:
133
- timestamp = driver.find_elements(By.CSS_SELECTOR, 'div.author-info > time')
 
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}] # Remove duplicates
137
 
138
  except Exception as e:
139
  st.error(f"Exception during comment extraction: {e}")
 
125
  try:
126
  wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#contents #contents")))
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.CSS_SELECTOR, 'div.author-info > time')
131
+ timestamp = timestamp_elements[0].get_attribute('datetime') if timestamp_elements else None
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}]
135
 
136
  except Exception as e:
137
  st.error(f"Exception during comment extraction: {e}")