{"id":20709983,"url":"https://github.com/oxylabs/walmart-price-tracker","last_synced_at":"2026-04-25T09:02:18.861Z","repository":{"id":215473044,"uuid":"738987300","full_name":"oxylabs/walmart-price-tracker","owner":"oxylabs","description":"Tutorial for creating a Walmart price tracker using Python and Oxylabs Walmart Scraper API.","archived":false,"fork":false,"pushed_at":"2025-04-09T08:37:37.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T09:36:39.810Z","etag":null,"topics":["scraper-api","walmart","walmart-api","walmart-scraper","web-scraping"],"latest_commit_sha":null,"homepage":"https://oxylabs.io/blog/walmart-price-tracker","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-04T14:09:44.000Z","updated_at":"2025-04-09T08:37:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"dffe9c89-4cfc-4280-bd41-5311eb5f211c","html_url":"https://github.com/oxylabs/walmart-price-tracker","commit_stats":null,"previous_names":["oxylabs/walmart-price-tracker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oxylabs/walmart-price-tracker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fwalmart-price-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fwalmart-price-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fwalmart-price-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fwalmart-price-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxylabs","download_url":"https://codeload.github.com/oxylabs/walmart-price-tracker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fwalmart-price-tracker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27593617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-08T02:00:07.111Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["scraper-api","walmart","walmart-api","walmart-scraper","web-scraping"],"created_at":"2024-11-17T02:09:27.414Z","updated_at":"2025-12-08T09:06:43.862Z","avatar_url":"https://github.com/oxylabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to Build Walmart Price Tracker With Python\n\n[![Oxylabs promo code](https://raw.githubusercontent.com/oxylabs/product-integrations/refs/heads/master/Affiliate-Universal-1090x275.png)](https://oxylabs.io/pages/gitoxy?utm_source=877\u0026utm_medium=affiliate\u0026groupid=877\u0026utm_content=walmart-price-tracker-github\u0026transaction_id=102f49063ab94276ae8f116d224b67)\n\n[![](https://dcbadge.limes.pink/api/server/Pds3gBmKMH?style=for-the-badge\u0026theme=discord)](https://discord.gg/Pds3gBmKMH) [![YouTube](https://img.shields.io/badge/YouTube-Oxylabs-red?style=for-the-badge\u0026logo=youtube\u0026logoColor=white)](https://www.youtube.com/@oxylabs)\n\nFollow this guide to learn how to track prices and availability of your desired Walmart products, and how to set up email alerts with the latest product and price change data.\n\nSee the [full blog post](https://oxylabs.io/blog/walmart-price-tracker) for comprehensive explanations about each step.\n\n- [1. Install libraries](#1-install-libraries)\n- [2. Import libraries](#2-import-libraries)\n- [3. Inspect elements to prepare XPaths](#3-inspect-elements-to-prepare-xpaths)\n  * [Title](#title)\n  * [Price](#price)\n  * [Product link](#product-link)\n- [4. Fetch Walmart category data](#4-fetch-walmart-category-data)\n  * [Set API credentials](#set-api-credentials)\n  * [Prepare parsing instructions](#prepare-parsing-instructions)\n  * [Prepare payload](#prepare-payload)\n  * [Send a POST request](#send-a-post-request)\n- [5. Track Walmart price history](#5-track-walmart-price-history)\n  * [Load history data](#load-history-data)\n  * [Track Walmart price changes and new products](#track-walmart-price-changes-and-new-products)\n  * [Save history data](#save-history-data)\n- [6. Create a price alert](#6-create-a-price-alert)\n  * [Configuration](#configuration)\n  * [Compose email](#compose-email)\n  * [Send email](#send-email)\n- [7. Full source code](#7-full-source-code)\n\n## 1. Install libraries\n```bash\npip install requests\n```\nNext, you’ll have to create an Oxylabs account to get the necessary credentials for the Walmart Scraper API. Register on the [Oxylabs dashboard](https://dashboard.oxylabs.io/) and claim a **1-week free trial**.\n\n## 2. Import libraries\n\n```python\nimport json\nimport smtplib\nfrom email.message import EmailMessage\nfrom pprint import pprint\nimport requests\n```\n\n## 3. Inspect elements to prepare XPaths\n\n### Title\n\n```xml\n//div[@role='group']//span[@data-automation-id='product-title']\n```\n\n### Price\n```xml\n//div[@role='group']//div[@data-automation-id='product-price']//span[@class='w_iUH7'][1]\n```\n\n### Product link\n```xml\n//div[@role='group']//a/@href\n```\n\n\n## 4. Fetch Walmart category data\n### Set API credentials\n```python\nusername, password = \"USERNAME\", \"PASSWORD\"\n```\nReplace `PASSWORD` and `USERNAME` with your API credentials. \n\n\n### Prepare parsing instructions\n```python\nparsing_instructions = {\n   \"titles\": {\n       \"_fns\": [\n           {\n               \"_fn\": \"xpath\",\n               \"_args\": [\n                   \"//div[@role='group']//span[@data-automation-id='product-title']/text()\"\n               ],\n           }\n       ]\n   },\n   \"links\": {\n       \"_fns\": [\n           {\n               \"_fn\": \"xpath\",\n               \"_args\": [\"//div[@role='group']//a/@href\"],\n           }\n       ]\n   },\n   \"prices\": {\n       \"_fns\": [\n           {\n               \"_fn\": \"xpath\",\n               \"_args\": [\n                   \"//div[@role='group']//div[@data-automation-id='product-price']//span[@class='w_iUH7'][1]/text()\"\n               ],\n           },\n           {\"_fn\": \"amount_from_string\"},\n       ]\n   },\n}\n```\nVisit our [documentation](https://developers.oxylabs.io/scraper-apis/custom-parser/list-of-functions) to learn more about the available functions and how to use them.\n\n### Prepare payload\n```python\nurl = \"https://www.walmart.com/cp/electronics/3944\"\n\n\npayload = {\n   \"source\": \"universal\",\n   \"url\": url,\n   \"parse\": True,\n   \"parsing_instructions\": parsing_instructions,\n}\n```\n\n### Send a POST request\n```python\nresponse = requests.post(\n   \"https://realtime.oxylabs.io/v1/queries\", auth=(username, password), json=payload\n)\nprint(response.status_code)\npprint(response.json())\n```\n\n## 5. Track Walmart price history\n### Load history data\n```python\nhistory = {}\n\n\ntry:\n   with open(\"walmart_data.json\", \"r\") as f:\n       history = json.load(f)\nexcept Exception as _:\n   pass\n```\n\n### Track Walmart price changes and new products\n```python\ncontent = response.json()[\"results\"][0][\"content\"]\nprice_changed = []\nnew_products = []\nfor title, price, link in zip(content[\"titles\"], content[\"prices\"], content[\"links\"]):\n   product = {\"title\": title, \"price\": price, \"link\": link}\n   if link not in history:\n       new_products.append(product)\n   elif history[link][\"price\"] != price:\n       product[\"old_price\"] = history[link][\"price\"]\n       price_changed.append(product)\n   history[link] = product\n```\n\n### Save history data\n```python\nwith open(\"walmart_data.json\", \"w\") as f:\n   f.write(json.dumps(history))\n```\n\n## 6. Create a price alert\n### Configuration\n```python\n# config\nSMTP_SERVER, SMTP_PORT = \"SERVER_ADDRESS\", \"SERVER_PORT\"\nemail, email_password, destination_email = \"from@email\", \"from_email_pass\", \"to@email\"\n```\n\nAs you can guess, you’ll have to replace these configs with appropriate data. For example, if you are using a Gmail account for sending email, you’ll have to set the `SERVER_ADDRESS` as `smtp.gmail.com` and `SERVER_PORT` must be set to `587`. `from@email` and `from_email_pass` should be set as per your sender email. Last but not least, `to@email` will be replaced with the receiver of the email notification. \n\nTo generate an app password for Gmail, you can do the following: \n\n- Go to your [Google account](https://myaccount.google.com/)\n- Select Security\n- Select 2-Step Verification under \"Signing in to Google\"\n- Select App passwords at the bottom of the page\n- Enter a name to help you remember where you'll use the app password\n- Select Generate\n- Copy and save the generated password\n\nFor more details, check out [Google's support documentation](https://support.google.com/mail/answer/185833?hl=en).\n\n### Compose email\n```python\nbody = f\"\"\"Price Changed:\n{json.dumps(price_changed, indent=2)}\nNew products:\n{json.dumps(new_products, indent=2)}\n\"\"\"\nmsg = EmailMessage()\nmsg.set_content(body)\nmsg[\"subject\"] = \"Walmart Price Tracking alert\"\nmsg[\"to\"] = destination_email\nmsg[\"from\"] = email\n```\n\n### Send email\n```python\nserver = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)\nserver.starttls()\nserver.login(email, email_password)\nserver.send_message(msg)\nserver.quit()\n```\n\n## 7. Full source code\n```python\nimport json\nimport smtplib\nfrom email.message import EmailMessage\nfrom pprint import pprint\nimport requests\n\n\nusername, password = \"USERNAME\", \"PASSWORD\"\n\nhistory = {}\n\n\ntry:\n   with open(\"walmart_data.json\", \"r\") as f:\n       history = json.load(f)\nexcept Exception as _:\n   pass\n\nurl = \"https://www.walmart.com/cp/electronics/3944\"\n\nparsing_instructions = {\n   \"titles\": {\n       \"_fns\": [\n           {\n               \"_fn\": \"xpath\",\n               \"_args\": [\n                   \"//div[@role='group']//span[@data-automation-id='product-title']/text()\"\n               ],\n           }\n       ]\n   },\n   \"links\": {\n       \"_fns\": [\n           {\n               \"_fn\": \"xpath\",\n               \"_args\": [\"//div[@role='group']//a/@href\"],\n           }\n       ]\n   },\n   \"prices\": {\n       \"_fns\": [\n           {\n               \"_fn\": \"xpath\",\n               \"_args\": [\n                   \"//div[@role='group']//div[@data-automation-id='product-price']//span[@class='w_iUH7'][1]/text()\"\n               ],\n           },\n           {\"_fn\": \"amount_from_string\"},\n       ]\n   },\n}\n\npayload = {\n   \"source\": \"universal\",\n   \"url\": url,\n   \"parse\": True,\n   \"parsing_instructions\": parsing_instructions,\n}\n\nresponse = requests.post(\n   \"https://realtime.oxylabs.io/v1/queries\", auth=(username, password), json=payload\n)\n\nprint(response.status_code)\npprint(response.json())\ncontent = response.json()[\"results\"][0][\"content\"]\nprice_changed = []\nnew_products = []\nfor title, price, link in zip(content[\"titles\"], content[\"prices\"], content[\"links\"]):\n   product = {\"title\": title, \"price\": price, \"link\": link}\n   if link not in history:\n       new_products.append(product)\n   elif history[link][\"price\"] != price:\n       product[\"old_price\"] = history[link][\"price\"]\n       price_changed.append(product)\n   history[link] = product\n   print(product)\nwith open(\"walmart_data.json\", \"w\") as f:\n   f.write(json.dumps(history))\n# Send email alert\nSMTP_SERVER, SMTP_PORT = \"SERVER_ADDRESS\", \"SERVER_PORT\"\nemail, email_password, destination_email = \"from@email\", \"from_email_pass\", \"to@email\"\nbody = f\"\"\"Price Changed:\n{json.dumps(price_changed, indent=2)}\nNew products:\n{json.dumps(new_products, indent=2)}\n\"\"\"\nmsg = EmailMessage()\nmsg.set_content(body)\nmsg[\"subject\"] = \"Walmart Price Tracking alert\"\nmsg[\"to\"] = destination_email\nmsg[\"from\"] = email\nserver = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)\nserver.starttls()\nserver.login(email, email_password)\nserver.send_message(msg)\nserver.quit()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fwalmart-price-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxylabs%2Fwalmart-price-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fwalmart-price-tracker/lists"}