nlpblogs commited on
Commit
aa2ff25
·
verified ·
1 Parent(s): 266103c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -127,11 +127,8 @@ 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
- 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}]
 
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}]