Skip to content

Instantly share code, notes, and snippets.

@gbit-is
Created May 18, 2024 16:58
Show Gist options
  • Save gbit-is/8c0a8e8b89ff16bcca65f12498b68c82 to your computer and use it in GitHub Desktop.
Save gbit-is/8c0a8e8b89ff16bcca65f12498b68c82 to your computer and use it in GitHub Desktop.
import requests
import json
def pprint(msg):
try:
print(json.dumps(msg,indent=2))
except:
print(msg)
import requests
import json
url = "https://tolvutek.is/api/FetchProducts"
payload = json.dumps({
"action": "1",
"productGroup": "",
"categoryId": 856,
"manufacturerId": 0,
"tags": [],
"manus": [],
"cats": [],
"page": 1,
"pageSize": 200,
"orderBy": "ORDER_BY_TIMES_VIEWED_DESCENDING",
"inStock": None,
"inStockReykjavik": None,
"inStockAkureyri": None,
"expected": None,
"customTag": "",
"filterPriceFrom": None,
"filterPriceTo": None
})
headers = {
'Accept': 'application/json',
'Accept-Language': 'en-GB,en;q=0.9,en-US;q=0.8,is;q=0.7',
'Cache': 'no-cache',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Content-Type': 'application/json',
'Origin': 'https://tolvutek.is',
'Pragma': 'no-cache',
'Referer': 'https://tolvutek.is/no-referrer',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
'sec-ch-ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"'
}
response = requests.request("POST", url, headers=headers, data=payload)
data = response.json()
products = data["currentProducts"]
pprint(products)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment