nlpblogs commited on
Commit
54fb744
·
verified ·
1 Parent(s): d29ce57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -120,16 +120,15 @@ if st.button("Sentiment Analysis", type="secondary"):
120
 
121
  placeholder.text("Scrolling complete.")
122
  progress_bar.empty()
123
-
124
- data = []
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
- st.write(comments)
129
- match = re.search(r'\d{4}-\d{2}-\d{2}', comment)
130
- timestamp = datetime.datetime.strptime(match.group(), '%Y-%m-%d').date()
131
- st.write(timestamp)
132
- except Exception as e:
133
- st.error(f"Exception during comment extraction: {e}")
134
-
135
 
 
120
 
121
  placeholder.text("Scrolling complete.")
122
  progress_bar.empty()
123
+ dates = []
124
+ wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#contents #contents")))
125
+ comments = driver.find_elements(By.CSS_SELECTOR, "#content #content-text")
126
+ st.write(comments)
127
+ for comment in comments:
128
+ comment_text = comment.text #Extract the text from the WebElement
129
+ date_match = re.search(r'(\d+ (day|week|month|year)s? ago)|(\d{4}-\d{2}-\d{2})', comment_text)
130
+ if date_match:
131
+ date_string = date_match.group(0) #Get the matched date string.
132
+ st.write(date_string) #for debug
133
+
 
134