Saketh Reddy commited on
Commit
8dbdcff
1 Parent(s): 0c81142

get product listing

Browse files
Files changed (1) hide show
  1. functions.py +60 -1
functions.py CHANGED
@@ -1,4 +1,5 @@
1
  import json
 
2
  import requests
3
 
4
  def call_function(messages, function_call):
@@ -73,4 +74,62 @@ def get_order_tracking_status(email_address: str, order_number: int) -> str:
73
 
74
  response = requests.request("POST", url, headers=headers, data=payload)
75
 
76
- return response.text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import json
2
+ from typing import Any, Dict
3
  import requests
4
 
5
  def call_function(messages, function_call):
 
74
 
75
  response = requests.request("POST", url, headers=headers, data=payload)
76
 
77
+ return response.text
78
+
79
+ def find_product_info(query: str) -> Dict[str, Any]:
80
+ url = "https://brickseek.com/api/brickseek-public"
81
+
82
+ payload = "{\"params\":{\"search\":\"Wireless Earbuds\",\"store_type\":10},\"url\":\"ajax/product_search\"}"
83
+ headers = {
84
+ 'authority': 'brickseek.com',
85
+ 'accept': '*/*',
86
+ 'accept-language': 'en-US,en;q=0.9',
87
+ 'baggage': 'sentry-environment=vercel-production,sentry-release=ca34a251f847fd72e72bf9f0656cea41aec74315,sentry-public_key=cdad1d45449541899fbf219ad1d6ebdb,sentry-trace_id=d9fb3a828b3045b688a444c93ebe25a0',
88
+ 'content-type': 'text/plain;charset=UTF-8',
89
+ 'cookie': '__cf_bm=HU3YnfBsggOePLMQc2lMbpEGvRS6XGg7aPex5VNdJ3Q-1700341559-0-AWvI96ju3QZHuINgeCgWv4wciLY8puzHv0o+iAitfuZARVg+dp4RAKSG/Pr0Gey2lUWsJj0ORKBaphLMq51IHpc=; cf_clearance=1Bd418eBhJTFAfAAdoK8d3I3EFpST.1ler5y0XFXf8k-1700341561-0-1-389cfab0.3c4718a5.6f9da550-0.2.1700341561',
90
+ 'origin': 'https://brickseek.com',
91
+ 'referer': 'https://brickseek.com/lowes-inventory-checker',
92
+ 'sec-ch-ua': '"Microsoft Edge";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
93
+ 'sec-ch-ua-mobile': '?0',
94
+ 'sec-ch-ua-platform': '"Windows"',
95
+ 'sec-fetch-dest': 'empty',
96
+ 'sec-fetch-mode': 'cors',
97
+ 'sec-fetch-site': 'same-origin',
98
+ 'sentry-trace': 'd9fb3a828b3045b688a444c93ebe25a0-874f3c7351675e10-1',
99
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
100
+ }
101
+
102
+ response = requests.request("POST", url, headers=headers, data=payload)
103
+
104
+ print(response.text)
105
+
106
+ # The output is a JSON object
107
+ # Turn it into a python dictionary
108
+ response_dict = json.loads(response.text)
109
+
110
+ return response_dict
111
+
112
+ def get_product_listing(sku: int):
113
+ url = f"https://www.lowes.com/search?searchTerm={sku}"
114
+
115
+ payload = {}
116
+ headers = {
117
+ 'authority': 'www.lowes.com',
118
+ 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
119
+ 'accept-language': 'en-US,en;q=0.9',
120
+ 'cookie': 'dbidv2=56b2862a-8fa1-4476-ae09-6368c4fab002; al_sess=FuA4EWsuT07UWryyq/3foEQIwIqOxmho8CAP0qIisJkWP6yrEciiDxJiF8HPZ/09; region=east; AKA_A2=A; EPID=NTZiMjg2MmEtOGZhMS00NDc2LWFlMDktNjM2OGM0ZmFiMDAy; bm_sz=FD2C6C9185843B61533705694D14EF09~YAAQTCXRFy7EGs+LAQAA9Cok5BVOqBRlOAkc2ibX247znTkInxYHj4yFBMY+lWEGSucc9Vag1mzB5owd7ujrIa8Tt+k8M+uWh6wPPUWz3QF7RpyIyxsA4NOmjVwds1rEkGCtXtnhtxNvg9eoBeVW2rKmOI+Wo6eeyG5ZD/Be3I8J0Mw859Xt03pOB7zh2NviHhi1rTbZLCqj7ihbL4OpgQWv4gd8p5JX2VOFHAjWA3xPtGEVZuPn3tcMJTKbETxO4xHmmO+ER0l6Pgsk+hDYu/G6s71XDkkcDyR2XosdOhO9sIYljoBjBCGktjJird6wvK8WJEC+9WFKdeY=~3486278~4604217; ph_aid=3c68acb4-b3eb-487a-fc03-1cd3fc616418-7080571749703-454eb8c121d15-bf29dec353e8d; sn=1875; sd=%7B%22id%22%3A%221875%22%2C%22zip%22%3A%2230307%22%2C%22city%22%3A%22Atlanta%22%2C%22state%22%3A%22GA%22%2C%22name%22%3A%22Atlanta-Edgewood%20Lowe\'s%22%2C%22region%22%3A%223%22%7D; zipcode=30307; nearbyid=1875; zipstate=GA; user=%7B%22zipPrompt%22%3Atrue%7D; audience=DIY; _abck=84784437A2290F7C7665B869C07C4FDE~0~YAAQTCXRFznOGs+LAQAApl0l5AoUWttzoglFBJBV0r/WGr6wXArpqRxmVKRftBWRNCD7Rc/+z809D45jGbTU0yldpjr9Jq5XeDPG1B6Gdkb3oeu+pL7t1YdLuYUU8pdsnTHiuNU6zW7wKAyzF7lmeXACJHQrlO7cN+zqBaTaile96J18Gj82+zHpDvkU1RuhcqH3rNlV8jq8Ecn8rminJr1LfE4xiOM6SH6yL0eFVl2T4wbNOpIhlZ7ycluXvEHEJQYrb8U3me7oJ0FVDbKXa8mi50c3LPk/maBSzz3LXvK8WwXAiMgWMnu7+D4r96p9YKKXVxiN2khwsm/YixV2j5vtGCEboSy+yWcBTZyDimKxpCf8JYbPRVvJyvgFmbEY/IZcDkueOCKIGxIsSfP+pyReapNRw0cvwmyBtzKDX4bnjU9lGGWZeoEUzwYzpheqs6Z2NyPpkpIl~-1~-1~-1; prodNumber=2; TAsessionID=a9359468-38d7-478b-98e3-860e86a1c42a|NEW; _lgsid=1700342200927; grs_search_token=HEAD:I3:1:NA:NA:b3dc2d9f6b133c15b34e9ca2541bf2dd; seo-partner=g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_id=0869bdc0-eb71-4df8-8a00-2581bdc455a1; akavpau_default=1700342511~id=d12fe16cb50bff6560c1af6055b1278c; akavpau_cart=1700342513~id=d28f6ce6f94e835c9677ad1aa459d716; notice_behavior=implied,eu; p13n=%7B%22zipCode%22%3A%2230307%22%2C%22storeId%22%3A%221875%22%2C%22state%22%3A%22GA%22%2C%22audienceList%22%3A%5B%5D%7D; g_previous=%7B%22gpvPageLoadTime%22%3A%220.00%22%2C%22gpvPageScroll%22%3A%2226%7C27%7C0%7C3149%22%2C%22gpvSitesections%22%3A%22checkorderstatus%22%2C%22gpvSiteId%22%3A%22desktop%22%2C%22gpvPageType%22%3A%22check-order-status%22%7D; akaalb_prod_dual=1700428639~op=PROD_GCP_EAST_CTRL_DFLT:PROD_DEFAULT_EAST|PROD_GCP_EAST_CTRL_A:PROD_EAST_A|~rv=89~m=PROD_DEFAULT_EAST:0|PROD_EAST_A:0|~os=352fb8a62db4e37e16b221fb4cefd635~id=2cf1cd354d83c94f9da60e4ebbc25c6e; bm_sv=8B13230A1BED940DF1CD6E283A4D1610~YAAQruULF7R42duLAQAAVpBL5BUdn0LlPXETpnblyyruPK4VG5bVhjNMqHn059CHQH/1BiSLnADboIS3aZWm2HrbjSicvoG6MsTqumzNORm9VzKfH3+PRzhqk0m7XDglfg2qO03xrSoMhn2x0HtBaFHYUu+LPlZYRrrU+chMrVHtzp5i8JTx3grQiWcJnahnj5Dm2Nm6r3d22ifqZG1hcxA9oNG69Kbiwinwv2B0Dt7kbujRggMq+dV/rHHmdyNF~1; _abck=84784437A2290F7C7665B869C07C4FDE~-1~YAAQruULFyp82duLAQAAjltO5Aq5Z2Wy7IwrT8LGPETsMNBYgR3ioKo05jXyjh7pnHJE/6HuQ48H84Qlbz3pLV0XC0Em8SxGIWwx4/jtqFwVP2HseXKdmJJm7bO5DHvTg1K7wu1LyubY7qU+eSTAxOMgnJiKjMy10pGMnVIsgS5/3UWvZprfNvZWYVFT/q6FtVpK7EOXXyI+FIherVv1IQBngeQbxFFT3sZ9yGVgcpuXffHW5G2ph7UB3sKQCVyU+XovIpman//ZoiNIBUrp9NR5pOoIA6ui8Wg8N4cm/bBUGRfxBCw4je16mWTbZP5Jm0XQvREBYvBBR8mXhP/iZvReV8YCMg5zjerxzeT3MGyzIipoLQeLxLzr9I/SUG5cHN7mXh8YFvmbuppyhnBQCTKrnhm8wZ+6Ga0eHY0jz9zhgSijOECuGxpnV4mdtC/rX7hswdMyAmmj~0~-1~-1; ak_bmsc=A80C29BEB24AF3C79480B0F09D37CF62~000000000000000000000000000000~YAAQruULFyt82duLAQAAjltO5BUVgHseFizgyiwC7KNxfqvcDdkjtdW0+ykbMNKpCOBkYKvRomJO8hYi+7pVA6Oi5vIWP7qYR9hLzp5KZz8nWu3DkYMpaDqbMTD16nRwkh36KS/NYhosAjQABuYoOUYw1IbBsr1L/uKHHOJv+jLyZcdpI92BOATTt/x7ZmVxVTJMH3Po+92V7gsXFvbJr281h3e41RVJUpUD4KG+4OfnJTaHuGqK5z2+Iw0hRvJtKDnWaaG9/iCLxLwFm9tFO7+8hDMW7SdoolHwKZ0KeajzTbYkugFRiTbH0SyKnM2zqMIt0hJfvIYsPkwzvxXR23BYoEl//ocbzN1Egsiknd83AtUgDG0qTMNJ/fpS8ey0Lpic9jk+qxm1aIozuv6wqZMcN+pCVuOZXMrV1YYo6Iifzr2z9dtTtufBvFQI6UrLBYVStlorAkMNO1ieotC48iLQoZnWa7Cex0FFNQ==; akaalb_prod_dual=1700426449~op=PROD_GCP_EAST_CTRL_DFLT:PROD_DEFAULT_EAST|PROD_GCP_EAST_CTRL_A:PROD_EAST_A|~rv=89~m=PROD_DEFAULT_EAST:0|PROD_EAST_A:0|~os=352fb8a62db4e37e16b221fb4cefd635~id=987589ee78f2a6df0f0ac4a0eb2f0327',
121
+ 'referer': 'https://www.lowes.com/c/Departments',
122
+ 'sec-ch-ua': '"Microsoft Edge";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
123
+ 'sec-ch-ua-mobile': '?0',
124
+ 'sec-ch-ua-platform': '"Windows"',
125
+ 'sec-fetch-dest': 'document',
126
+ 'sec-fetch-mode': 'navigate',
127
+ 'sec-fetch-site': 'same-origin',
128
+ 'sec-fetch-user': '?1',
129
+ 'upgrade-insecure-requests': '1',
130
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
131
+ }
132
+
133
+ response = requests.request("GET", url, headers=headers, data=payload)
134
+
135
+ return response.text