Skip to content

Commit

Permalink
reader for dell.com
Browse files Browse the repository at this point in the history
  • Loading branch information
builder555 committed Jan 7, 2024
1 parent 39c24d1 commit 5c6979b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/readers/dell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import random
import re
import httpx
from .__agents import agents

SITE = "www.dell.com"


def get_price(url: str, client: httpx.Client) -> float:
agent = random.choice(agents)
r = client.get(url, headers={"User-Agent": agent}, timeout=10)
html = r.text
pattern = r'"price"\s*\:\s*"(\d+\.?\d*)"'
matches = re.findall(pattern, html)
price = matches[0]
return float(price.strip().strip("$").strip())

0 comments on commit 5c6979b

Please sign in to comment.