Skip to content

Commit

Permalink
remove instacart dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
dax-dot-gay committed Nov 11, 2023
1 parent 12914fd commit 99166d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
15 changes: 3 additions & 12 deletions open_groceries/adapters/wegmans.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


WG_MAP = "pk.eyJ1IjoiaW5zdGFjYXJ0IiwiYSI6ImNqcmJrZWpmYjE0YXI0M3BkZHF2MXA4eXEifQ.YLQlO13ZFAJMx6ew3rvBrw"
WG_INSTA = "Bearer v2.2aaf35d6a9f7e4.AUjoCP_kvwWqLABrsBF8A-L6WvgCU9QKMgNLH7Jh3RQ"


@dataclass
Expand Down Expand Up @@ -164,20 +163,12 @@ def set_location(self, location: Location):
self.session.cookies.set("wfmStoreId", location.id)

def suggest(self, search: str) -> list[str]:
result = requests.post(
"https://connect.instacart.com/v2/autosuggest/autosuggestions",
json={"limit": 10, "query": search},
headers={
"authorization": WG_INSTA,
"User-Agent": self.context.user_agent,
"Host": "connect.instacart.com",
"Origin": "https://shop.wegmans.com",
"Referer": "https://shop.wegmans.com/"
},
result = self.session.get(
self.url("/api/v2/autocomplete"), params={"search_term": search}
)

if result.status_code >= 300:
raise ApiException(result)

data = result.json()
return [s["text"] for s in data["autosuggestions"]]
return [s.replace("<strong>", "").replace("</strong>", "") for s in data["product_autocompletes"]]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "open-groceries"
version = "0.2.0"
version = "0.2.1"
description = "Unified data acquisition across multiple grocery store sites"
authors = ["Dax Harris <[email protected]>"]
license = "MIT"
Expand Down
3 changes: 1 addition & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

groc = OpenGrocery()
groc.set_nearest_stores("Rochester Institute of Technology")
#print(groc.search("beans", include=["costco"]))
print([i.categories for i in groc.search("beans")])
print(groc.suggest("pot"))

0 comments on commit 99166d0

Please sign in to comment.