Created
February 10, 2025 23:01
-
-
Save jhyland87/83e25dd5d0b7e101bf9495739e276218 to your computer and use it in GitHub Desktop.
Simple price fetcher for laboratoriumdiscounter
This file contains hidden or 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
import requests | |
import sys | |
search_string = sys.argv[1] | |
headers = { | |
'accept': 'application/json, text/javascript, */*; q=0.01', | |
'referer': 'https://www.laboratoriumdiscounter.nl/en/', | |
'x-requested-with': 'XMLHttpRequest', | |
} | |
params = { | |
'limit': '6', | |
} | |
response = requests.get( | |
f"https://www.laboratoriumdiscounter.nl/en/search/{search_string}/page1.ajax", | |
params=params, | |
headers=headers, | |
) | |
response_obj = response.json() | |
sorted_products = sorted(response_obj['products'], key=lambda p: p['price']['price'], reverse=False) | |
lowest_price = sorted_products[0] | |
print("{price} - {product_name}".format(price=lowest_price['price']['price_money'], product_name=lowest_price['fulltitle'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment