CoolFace
Apppublic

mydatascraper/competitor_compare

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
compare.cpython-314.pyc63 linesDownload Raw Back to __pycache__
1+
2J�2j0��F�^RIHtHt^RIHtHt^RIHt^RIH	t	H3t4Ht]!RR.R7t]!4t
]PR]	R	7]!R5R^^�R7]!R
RR73RRll4t]P!R]R	7]!R
43RRll4t]PR4R4tR
#)�)�	APIRouter�Query)�Optional�List)�ComparisonService)�ComparisonResponse�MultiCompareRequest�MultiCompareResponsez/api/v1zPrice Comparison)�prefix�tagsz/compare)�response_model.zNProduct name to search (e.g., 'whole milk', 'cheerios 18oz', 'pampers size 3'))�description�6min_length�7max_lengthNz<Filter to specific retailers: walmart, aldi, target, wegmans)rc�\�V^8�dQhR\R\\\,,/#)��product�	retailers)�strrr)�formats"�XC:\Users\Asus\PycharmProjects\grocery-price-api\grocery-price-api\app\routers\compare.py�__annotate__rs+��&@�&@�
�&@���S�	�"�&@�c��H"�\PW4GRjx�L8#L5i)u�9## Compare grocery prices in real-time10 11Searches Walmart, Aldi, Target, and Wegmans simultaneously12for the given product and returns a price comparison.13 14### How it works151. Sends search query to all 4 retailer websites concurrently162. Parses product listings from each site173. Finds the best matching product per retailer184. Ranks by price and returns comparison19 20### Fallback Strategy21For each retailer, tries 3 methods in order:22- **httpx** → Fast async HTTP (tries API endpoints first)23- **cloudscraper** → Handles Cloudflare/bot protection24- **playwright** → Full headless browser (last resort)25 26### Example Queries27- `whole milk`28- `cheerios`29- `boneless chicken breast`30- `pampers diapers size 3`31- `tide pods`32- `banana`33N)�comparison_service�compare)rrs&&r�compare_pricesrs���N$�+�+�G�?�?�?�?�s�"� �"z/compare/batchc�\�V^8�dQhR\R\\\,,/#)r�requestr)r	rrr)rs"rrr:s)��G�G�
 �G���S�	�"�Grc��n"�VPR,p\PW!4GRjx�L34#L5i)a�35## Compare multiple products at once36 37Submit a list of product names and get comparison38results for each across all retailers.39 40### Example Request41```json42{43    "products": [44        "whole milk",45        "cheerios",46        "bananas",47        "ground beef"48    ]49}50```51 52**Note:** Each product triggers concurrent searches across all retailers.53More products = longer response time. Limit: 10 products per request.54:N�55NN)�productsr�
multi_compare)rrr"s&& r�compare_multiple_productsr$9s.���6����$�H�#�1�1�(�F�F�F�F�s�,5�3�5z56/retailersc��r"�RRRRRRRRR	R57R/RRRR
RRRR	R58R/RRRRRRRR	R59R/RRRRRRRR	R60R/.R^RR/#5i)z.List all supported retailers and their status.r�id�walmart�name�Walmart�websitezhttps://www.walmart.com�coveragezFull - PA stores�status�active�aldi�ALDIzhttps://www.aldi.us�target�Targetzhttps://www.target.com�wegmans�Wegmanszhttps://shop.wegmans.com�total�notezxPhase 2 will add: Sam's Club, Costco, Lidl, Trader Joe's, Whole Foods, Giant Eagle, Giant/Martin's, Weis, ShopRite, Acme�r6rr�list_retailersr7Xs����	��i��	��4��.��(�
��f����0��.��(�
��h����3��.��(�
��i��	��5��.��(�
�-61�<	���Q�A"�"�s�57)�fastapirr�typingrr�app.services.comparison_servicer�app.schemasrr	r62�routerr�getr�postr$r7r6rr�<module>r?s���$�!�=���63�)�+=�*>�	?��&�(�����J�'9��:���d���	�&+��R�&�&@�;�&@�R���
�.B��C�&+�4�[�G�D�G�<���L��$��$r