From 0063651514667205bad02774c37ab3c2f6ed1e5a Mon Sep 17 00:00:00 2001 From: hong-sile Date: Sun, 18 Feb 2024 15:34:01 +0900 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20firefox=EB=93=9C=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B2=84=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #29 --- .../java/com/gdsc/goodeat/domain/FoodScraper.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java b/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java index 4adb603..2803e3f 100644 --- a/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java +++ b/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java @@ -13,9 +13,12 @@ import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.springframework.stereotype.Component; +@Component public class FoodScraper { + private static final String TASTEATLAS_URL = "https://www.tasteatlas.com/"; private static final String FOOD_IMG_NOT_FOUND_URL = "https://storage.googleapis.com/goodeat/food_image_not_found.jpg"; private static final Duration DEFAULT_IMPLICIT_WAIT_DURATION = Duration.ofSeconds(5); @@ -26,12 +29,11 @@ public class FoodScraper { private final WebDriver driver; - public FoodScraper() { - this.driver = new ChromeDriver(); + this.driver = new FirefoxDriver(); } - public List scrape(List foodList) { + public List scrape(final List foodList) { List foodInfoList = new ArrayList<>(); for (String foodName : foodList) { @@ -94,6 +96,7 @@ private FoodInfo extractFoodInfo() { @Data @AllArgsConstructor public static class FoodInfo { + private String image; private String description; From 6e870e1d3bef5033ac8658632c64aab2bd32f26f Mon Sep 17 00:00:00 2001 From: hong-sile Date: Sun, 18 Feb 2024 15:45:50 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=ED=81=AC=EB=A1=AC=20=EB=93=9C?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B2=84=EB=A5=BC=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=9E=AC=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #29 --- src/main/java/com/gdsc/goodeat/domain/FoodScraper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java b/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java index 2803e3f..5407177 100644 --- a/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java +++ b/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java @@ -13,6 +13,7 @@ import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.springframework.stereotype.Component; @@ -30,7 +31,7 @@ public class FoodScraper { private final WebDriver driver; public FoodScraper() { - this.driver = new FirefoxDriver(); + this.driver = new ChromeDriver(); } public List scrape(final List foodList) { From 75873bd20c283df24b7c9dd9d6378b83492acbe6 Mon Sep 17 00:00:00 2001 From: hong-sile Date: Sun, 18 Feb 2024 15:46:04 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20selenium=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=93=9C=EB=9D=BC=EC=9D=B4=EB=B2=84=20=EC=84=A4?= =?UTF-8?q?=EC=B9=98=20=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #29 --- .github/workflows/build-test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 7ff3f73..7c44071 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -22,6 +22,13 @@ jobs: java-version: 17 distribution: 'temurin' + - name: selenium을 위한 드라이버 설치 + run: | + wget https://chromedriver.storage.googleapis.com/100.0.4896.20//chromedriver_linux64.zip + unzip chromedriver_linux64.zip + chmod +x chromedriver + mv chromedriver /usr/local/bin/ + - name: Give permission for Gradle run: chmod +x gradlew From fe4e884ee65472b56f154004c46e7b993feeb505 Mon Sep 17 00:00:00 2001 From: hong-sile Date: Sun, 18 Feb 2024 15:47:58 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20=ED=81=AC=EB=A1=AC=20=EB=93=9C?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B2=84=20=EA=B2=BD=EB=A1=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #29 --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 7c44071..511cd41 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -24,7 +24,7 @@ jobs: - name: selenium을 위한 드라이버 설치 run: | - wget https://chromedriver.storage.googleapis.com/100.0.4896.20//chromedriver_linux64.zip + wget https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip unzip chromedriver_linux64.zip chmod +x chromedriver mv chromedriver /usr/local/bin/ From c6526b12cf47a35d80049b3056e0e2d268963979 Mon Sep 17 00:00:00 2001 From: hong-sile Date: Sun, 18 Feb 2024 16:27:01 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20chrome=20option=20headless=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #29 --- src/main/java/com/gdsc/goodeat/domain/FoodScraper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java b/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java index 5407177..45849a9 100644 --- a/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java +++ b/src/main/java/com/gdsc/goodeat/domain/FoodScraper.java @@ -14,7 +14,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.chrome.ChromeOptions; import org.springframework.stereotype.Component; @Component @@ -31,7 +31,9 @@ public class FoodScraper { private final WebDriver driver; public FoodScraper() { - this.driver = new ChromeDriver(); + ChromeOptions options = new ChromeOptions(); + options.addArguments("--headless"); + this.driver = new ChromeDriver(options); } public List scrape(final List foodList) { From 175646a6b33131b07c156970894ba79b7b55783b Mon Sep 17 00:00:00 2001 From: hong-sile Date: Sun, 18 Feb 2024 16:30:20 +0900 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20selenium=20=EB=93=9C=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=B2=84=20=EC=84=A4=EC=B9=98=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=84=B8=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #29 --- .github/workflows/build-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 511cd41..77a6a0c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -22,12 +22,12 @@ jobs: java-version: 17 distribution: 'temurin' - - name: selenium을 위한 드라이버 설치 + - name: selenium을 위한 chrome 드라이버 설치 run: | - wget https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - chmod +x chromedriver - mv chromedriver /usr/local/bin/ + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' + sudo apt-get update + sudo apt-get install google-chrome-stable - name: Give permission for Gradle run: chmod +x gradlew