-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39c24d1
commit 5c6979b
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |