Skip to content

Commit

Permalink
merge: 셀레니움 오류 수정
Browse files Browse the repository at this point in the history
fix: firefox드라이버를 사용하도록 변경
  • Loading branch information
hong-sile authored Feb 18, 2024
2 parents 4395a3e + 175646a commit 37744f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
java-version: 17
distribution: 'temurin'

- name: selenium을 위한 chrome 드라이버 설치
run: |
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

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/com/gdsc/goodeat/domain/FoodScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
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);
Expand All @@ -26,12 +30,13 @@ 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<FoodInfo> scrape(List<String> foodList) {
public List<FoodInfo> scrape(final List<String> foodList) {
List<FoodInfo> foodInfoList = new ArrayList<>();

for (String foodName : foodList) {
Expand Down Expand Up @@ -94,6 +99,7 @@ private FoodInfo extractFoodInfo() {
@Data
@AllArgsConstructor
public static class FoodInfo {

private String image;
private String description;

Expand Down

0 comments on commit 37744f1

Please sign in to comment.