Skip to content

Commit

Permalink
refactor: replace ScraperWebDriver with requests for fetching item data
Browse files Browse the repository at this point in the history
  • Loading branch information
Flexicon committed Jan 10, 2025
1 parent 1be09ae commit c17a2c5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scraper/scrape_items.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import requests

from typing import List

from bs4 import BeautifulSoup, Tag
from pymongo.collection import Collection

from common.models import CompositeItem, Item
from common.db import DB
from .helpers import ScraperWebDriver

ScrapeURL = r"https://www.mobafire.com/teamfight-tactics/items-cheatsheet"
Selector = ".mobile-items .item"
Expand Down Expand Up @@ -37,9 +38,11 @@


def scrape_items() -> List[CompositeItem]:
with ScraperWebDriver() as driver:
html = driver.fetch_content_html(ScrapeURL, selector="#content")
items = BeautifulSoup(html, "html.parser").select(Selector)
print(f"Fetching items from: {ScrapeURL}")
res = requests.get(ScrapeURL)
res.raise_for_status()

items = BeautifulSoup(res.text, "html.parser").select(Selector)
return list(map(_build_composite_item, items))


Expand Down

0 comments on commit c17a2c5

Please sign in to comment.