Spaces:
Sleeping
Sleeping
Update app.py
Browse files67 unmodified lines686970717172737475767778798081828384858687888990919293949596979899100737475101777810210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313467 unmodified lines elif predict_answer == 1: st.write("(๊ธ์ ํ๋ฅ : %.2f) ๊ธ์ ์ ์ธ ์ํ ํ๊ฐ์
๋๋ค." % predict_value)
sentiment_model = create_sentiment_bert()def setup_driver(): chrome_options = Options() chrome_options.add_argument("--headless") # ๋ฐฑ๊ทธ๋ผ์ด๋ ์คํ chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--disable-dev-shm-usage") driver = webdriver.Chrome(options=chrome_options) return driver
def scrape_content(url): driver = setup_driver() try: driver.get(url) # ํ์ด์ง ๋ก๋ฉ ๋๊ธฐ time.sleep(3) # ๋ณธ๋ฌธ ์ถ์ถ soup = BeautifulSoup(driver.page_source, 'html.parser') content = soup.find('article') # ๋ณธ๋ฌธ ํ๊ทธ์ ๋ง๊ฒ ์์ # ๋๊ธ ์ถ์ถ comments = soup.find_all('span', class_='u_cbox_contents') # ๋๊ธ ํ๊ทธ์ ๋ง๊ฒ ์์ return { 'content': content.text if content else "๋ณธ๋ฌธ์ ์ฐพ์ ์ ์์ต๋๋ค.", 'comments': [comment.text for comment in comments] } finally: driver.quit()
test = st.form('test')sentence = test.text_input("Your sentence")submit = test.form_submit_button("Submit")
if submit: movie_evaluation_predict(sentence)def main(): sentiment_model = create_sentiment_bert()
url = st.text_input("URL์ ์
๋ ฅํ์ธ์") if st.button("ํฌ๋กค๋ง ์์"): if url: with st.spinner("ํฌ๋กค๋ง ์ค..."): result = scrape_content(url) st.subheader("๋ณธ๋ฌธ") st.write(result['content']) st.subheader("๋๊ธ") for idx, comment in enumerate(result['comments'], 1): st.write(f"{idx}. {comment}") else: st.error("URL์ ์
๋ ฅํด์ฃผ์ธ์")
''' test = st.form('test') sentence = test.text_input("Your sentence") submit = test.form_submit_button("Submit") if submit: movie_evaluation_predict(sentence) ''' return 0
if __name__ == "__main__": main() app.py+61-6