From 7dd80748712c0f6984eb8de49b39f87670b48835 Mon Sep 17 00:00:00 2001 From: chaewonjeong Date: Mon, 22 Jul 2024 11:48:33 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20selenium=20headless=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crawlingserver/main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crawlingserver/main.py b/crawlingserver/main.py index 7667d31..5660413 100644 --- a/crawlingserver/main.py +++ b/crawlingserver/main.py @@ -8,6 +8,8 @@ from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import TimeoutException +from selenium.webdriver.chrome.service import Service +from webdriver_manager.chrome import ChromeDriverManager app = FastAPI() @@ -20,10 +22,19 @@ class Song(BaseModel): class SongRequest(BaseModel): songs: List[Song] +options = wb.ChromeOptions() +options.add_argument('headless') +options.add_argument('window-size=1920x1080') +options.add_argument("disable-gpu") +options.add_argument(f'user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36') + +service = Service(executable_path=ChromeDriverManager().install()) + + #json request 요청양식은 이쪽에서 정의 @app.post("/getYoutubeUrls") async def get_youtube_urls(request: SongRequest): - driver = wb.Chrome() + driver = wb.Chrome(service=service, options=options) results = [] for song in request.songs: song_id = song.songId From a563698f994ffa46aaded474fe6f2ec7a28396ee Mon Sep 17 00:00:00 2001 From: chaewonjeong Date: Mon, 22 Jul 2024 16:08:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=ED=94=8C=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=83=9D=EC=84=B1=20=EB=A6=AC?= =?UTF-8?q?=EB=8B=A4=EC=9D=B4=EB=A0=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- turntable/src/main/webapp/WEB-INF/views/todayPlaylist.jsp | 1 + 1 file changed, 1 insertion(+) diff --git a/turntable/src/main/webapp/WEB-INF/views/todayPlaylist.jsp b/turntable/src/main/webapp/WEB-INF/views/todayPlaylist.jsp index 8a459ae..62652b8 100644 --- a/turntable/src/main/webapp/WEB-INF/views/todayPlaylist.jsp +++ b/turntable/src/main/webapp/WEB-INF/views/todayPlaylist.jsp @@ -312,6 +312,7 @@ success: function(response) { console.log("Playlist saved successfully:", response); alert("플레이리스트가 성공적으로 저장되었습니다!"); + window.location.href = "/main"; }, error: function(xhr, status, error) { console.error(`Error: ${'${status}'}, ${error}`);