diff --git a/.github/workflows/ratings.yml b/.github/workflows/ratings.yml deleted file mode 100644 index 8839bbd..0000000 --- a/.github/workflows/ratings.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Update Ratings - -on: - schedule: - # every 14 days - - cron: "0 15 3 * *" - - # can be triggered manually - workflow_dispatch: - -jobs: - update_ratings: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4.1.1 - - - name: Install Nix - uses: cachix/install-nix-action@v26 - - - name: Use Cachix - uses: cachix/cachix-action@v12 - with: - name: devenv - - - name: Install devenv.sh - run: nix profile install --accept-flake-config tarball+https://install.devenv.sh/latest - - - name: Build the devenv shell and run any pre-commit hooks - run: devenv ci - - - name: Run tests - run: devenv shell run_tests - - - name: Run update_reviews - run: devenv shell update_reviews - - - name: Add & Commit - uses: EndBug/add-and-commit@v9.1.4 - with: - message: update data.yaml via update_reviews.py diff --git a/devenv.nix b/devenv.nix index c159dcb..927221e 100644 --- a/devenv.nix +++ b/devenv.nix @@ -3,7 +3,7 @@ { packages = [ pkgs.chromedriver - pkgs.chromium + # pkgs.chromium ]; languages.python = { diff --git a/src/update_reviews.py b/src/update_reviews.py index 7028a37..cb0c247 100644 --- a/src/update_reviews.py +++ b/src/update_reviews.py @@ -27,8 +27,10 @@ def dump_data(data): chrome_options = Options() -chrome_options.add_argument("--headless") -binary_location = "/nix/store/5hmqjx40frw4cf3gm2zz66s6hzrr0pjc-chromium-106.0.5249.61/bin/chromium" +# chrome_options.add_argument("--headless") +binary_location = ( + "/nix/store/5hmqjx40frw4cf3gm2zz66s6hzrr0pjc-chromium-106.0.5249.61/bin/chromium" +) chrome_options.binary_location = binary_location driver = webdriver.Chrome(options=chrome_options) @@ -45,7 +47,6 @@ def dump_data(data): for index, job in enumerate(jobs): url = job["review"] - job["rating"] = None if url: print(url + ": ", end="", flush=True) @@ -56,9 +57,12 @@ def dump_data(data): try: offset = 56 rating = float( - content[index + offset: index + - offset + 3].replace(",", ".") + content[index + offset : index + offset + 3].replace( + ",", "." + ) ) + print(rating) + job["rating"] = rating except ValueError as error: print(error) @@ -66,13 +70,15 @@ def dump_data(data): try: driver.get(url) rating = driver.find_element( - By.CLASS_NAME, "v2__EIReviewsRatingsStylesV2__ratingNum").text + By.CLASS_NAME, + "rating-headline-average__rating-headline-average-module__rating", + ).text + print(rating) + job["rating"] = rating except Exception as e: print("error getting rating", e) - print(rating) - job["rating"] = rating - time.sleep(random.randint(1, 4)) + time.sleep(random.randint(10, 20)) dump_data(data) except yaml.YAMLError as error: