Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created February 10, 2025 23:01
Show Gist options
  • Save jhyland87/83e25dd5d0b7e101bf9495739e276218 to your computer and use it in GitHub Desktop.
Save jhyland87/83e25dd5d0b7e101bf9495739e276218 to your computer and use it in GitHub Desktop.
Simple price fetcher for laboratoriumdiscounter
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