From 1bf56ccee7e7b1f26dab13c808790564559da094 Mon Sep 17 00:00:00 2001 From: ehsang Date: Sat, 21 Sep 2024 18:38:18 +0330 Subject: [PATCH] fresh product changes --- say/celery.py | 2 +- say/crawler/__init__.py | 4 +- ...\330\255.\330\252\330\263\330\256\330\257" | 454 ------------------ 3 files changed, 3 insertions(+), 457 deletions(-) delete mode 100644 "\331\201\330\253\331\276\330\255.\330\252\330\263\330\256\330\257" diff --git a/say/celery.py b/say/celery.py index 1f0ef62c..fbe562b2 100644 --- a/say/celery.py +++ b/say/celery.py @@ -23,7 +23,7 @@ }, 'update-needs': { 'task': 'say.tasks.update_needs.update_needs', - 'schedule': crontab(minute=15, hour='0,4,8,12,16,20'), + 'schedule': crontab(minute=15, hour='0,4,8,12,15,20'), }, 'report_to_family': { 'task': 'say.tasks.report_to_family.report_to_families', diff --git a/say/crawler/__init__.py b/say/crawler/__init__.py index 95dc077b..136d647f 100644 --- a/say/crawler/__init__.py +++ b/say/crawler/__init__.py @@ -115,7 +115,7 @@ def __init__(self, url): except IndexError: self.dkp = None - def get_data(self, need_id, force=False): + def get_data(self, force=False): if self.dkp is None: return @@ -126,10 +126,10 @@ def get_data(self, need_id, force=False): r = request_with_cache(url) if r.status_code != 200: return + result = r.json() # fresh products have different api / Digikala redirect to new link for fresh product # Typical response: {'status': 302, 'redirect_url': {'base': None, 'uri': '/fresh/product/dkp-10269403/'}} - result = r.json() if result["status"] == 302 and "fresh" in result["redirect_url"]["uri"]: url = self.API_URL_FRESH % self.dkp if force: diff --git "a/\331\201\330\253\331\276\330\255.\330\252\330\263\330\256\330\257" "b/\331\201\330\253\331\276\330\255.\330\252\330\263\330\256\330\257" deleted file mode 100644 index 1efeca71..00000000 --- "a/\331\201\330\253\331\276\330\255.\330\252\330\263\330\256\330\257" +++ /dev/null @@ -1,454 +0,0 @@ -{ - "status": 200, - "data": { - "product": { - "id": 792148, - "title_fa": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "title_en": "Mahya Protein Chicken Barbecue Drumstick - 0.9 Kg", - "url": { - "uri": "/product/dkp-792148/جوجه-کباب-ران-مرغ-مهیا-پروتئین-09-کیلوگرم" - }, - "status": "out_of_stock", - "has_quick_view": false, - "data_layer": { - "brand": "مهیا پروتئین", - "category": "[FF,گوشت مرغ]", - "metric6": 2173, - "dimension2": 0, - "dimension6": 0, - "dimension7": "none", - "dimension9": 4.3, - "dimension11": 0, - "dimension20": "out_of_stock", - "item_category2": "مواد پروتئینی و تخم مرغ", - "item_category3": "", - "item_category4": "", - "item_category5": "" - }, - "product_type": "product", - "digiplus": { - "services": [ - "۴ ارسال رایگان ماهانه + ۲ ارسال رایگان بیشتر، ویژه سوپرمارکت", - "پشتیبانی اختصاصی" - ], - "services_summary": [ - "ارسال رایگان" - ], - "is_jet_eligible": false, - "cash_back": 0, - "is_general_location_jet_eligible": false - }, - "images": { - "main": { - "url": [ - "https://dkstatics-public.digikala.com/digikala-products/3d70b4ef3f0647dc67a7ae086755afdd21b9ff2b_1675085791.jpg?x-oss-process=image/resize,m_lfit,h_800,w_800/quality,q_90" - ], - "webp_url": [ - "https://dkstatics-public.digikala.com/digikala-products/3d70b4ef3f0647dc67a7ae086755afdd21b9ff2b_1675085791.jpg?x-oss-process=image/resize,m_lfit,h_800,w_800/format,webp/quality,q_90" - ] - }, - "list": [ - { - "url": [ - "https://dkstatics-public.digikala.com/digikala-products/1f85d2dab3ceb24b47d37cd1b6d4f21a09058417_1675085790.jpg?x-oss-process=image/resize,m_lfit,h_800,w_800/quality,q_90" - ], - "webp_url": [ - "https://dkstatics-public.digikala.com/digikala-products/1f85d2dab3ceb24b47d37cd1b6d4f21a09058417_1675085790.jpg?x-oss-process=image/resize,m_lfit,h_800,w_800/format,webp/quality,q_90" - ] - } - ] - }, - "rating": { - "rate": 84.03037275655775, - "count": 2173 - }, - "properties": { - "is_fast_shipping": false, - "is_ship_by_seller": false, - "free_shipping_badge": false, - "is_multi_warehouse": false, - "is_fake": false, - "has_gift": false, - "min_price_in_last_month": 1746000, - "is_non_inventory": false, - "is_ad": false, - "is_jet_eligible": false, - "is_medical_supplement": false, - "has_printed_price": true - }, - "has_true_to_size": false, - "category": { - "id": 84, - "title_fa": "گوشت مرغ", - "title_en": "Chicken", - "code": "chicken", - "return_reason_alert": "به دلیل ماهیت و شرایط ویژه نگهداری و ارسال این گروه کالایی، درخواست مرجوع کردن آن با دلیل «انصراف از خرید» قابل تایید نیست." - }, - "brand": { - "id": 8897, - "code": "mahya-protein", - "title_fa": "مهیا پروتئین", - "title_en": "Mahya Protein", - "url": { - "uri": "/brand/mahya-protein/" - }, - "visibility": true, - "logo": { - "url": [ - "https://dkstatics-public.digikala.com/digikala-brands/477ab48bb7261595c02cb0f4c504837e464f00d0_1663485028.jpg?x-oss-process=image/resize,m_lfit,h_120,w_120/quality,q_80" - ] - }, - "is_premium": false, - "is_miscellaneous": false, - "is_name_similar": false - }, - "pros_and_cons": [], - "suggestion": { - "count": 600, - "percentage": 85 - }, - "questions_count": 3, - "comments_count": 775, - "breadcrumb": [ - { - "title": "سوپرمارکت", - "url": { - "uri": "/" - } - }, - { - "title": "مواد پروتئینی و تخم مرغ", - "url": { - "uri": "/search/category-protein-foods/" - } - }, - { - "title": "گوشت مرغ", - "url": { - "uri": "/search/category-chicken/" - } - }, - { - "title": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "url": { - "uri": "/product/dkp-792148/%D8%AC%D9%88%D8%AC%D9%87-%DA%A9%D8%A8%D8%A7%D8%A8-%D8%B1%D8%A7%D9%86-%D9%85%D8%B1%D8%BA-%D9%85%D9%87%DB%8C%D8%A7-%D9%BE%D8%B1%D9%88%D8%AA%D8%A6%DB%8C%D9%86-09-%DA%A9%DB%8C%D9%84%D9%88%DA%AF%D8%B1%D9%85" - } - } - ], - "specifications": [ - { - "title": "مشخصات", - "attributes": [ - { - "title": "وزن بسته‌بندی", - "values": [ - "0.9 گرم" - ] - }, - { - "title": "ابعاد بسته‌بندی", - "values": [ - "22 × 17 × 4 سانتی‌متر" - ] - }, - { - "title": "شماره پروانه بهداشت", - "values": [ - "IVC913961227824900 " - ] - }, - { - "title": "طعم", - "values": [ - "ساده " - ] - }, - { - "title": "سایر توضیحات", - "values": [ - "مناسب برای مصارف خانوار\r\nعرضه شده در ظرف با جنس پلی پروپیلن " - ] - } - ] - } - ], - "expert_reviews": { - "description": "", - "short_review": "", - "technical_properties": [] - }, - "meta": { - "brand_category_url": { - "uri": "/search/category-chicken/mahya-protein/" - } - }, - "last_comments": [ - { - "id": 65689093, - "body": "یه کم بو گرفته بود", - "created_at": "27 شهریور 1403", - "rate": 4, - "reactions": { - "likes": 0, - "dislikes": 0 - }, - "recommendation_status": "recommended", - "is_buyer": true, - "user_name": "سید زهیر مرتضوی", - "is_anonymous": false - }, - { - "id": 65625902, - "title": "", - "body": "تازه و خوب", - "created_at": "25 شهریور 1403", - "rate": 5, - "reactions": { - "likes": 0, - "dislikes": 0 - }, - "recommendation_status": "recommended", - "is_buyer": true, - "user_name": "سمانه قاسمی", - "is_anonymous": false - }, - { - "id": 65564545, - "title": "", - "body": "تازه بود ولی خودتون هم باید پاکش کنین چون کمی غضروف داره", - "created_at": "23 شهریور 1403", - "rate": 3, - "reactions": { - "likes": 0, - "dislikes": 0 - }, - "recommendation_status": "recommended", - "is_buyer": true, - "user_name": "فریبا صفاری فر", - "is_anonymous": false - }, - { - "id": 65368906, - "body": "خوب", - "created_at": "16 شهریور 1403", - "rate": 5, - "reactions": { - "likes": 0, - "dislikes": 0 - }, - "recommendation_status": "recommended", - "is_buyer": true, - "user_name": "کاربر دیجی‌کالا", - "is_anonymous": true - } - ], - "last_questions": [ - { - "id": 4985418, - "status": "accepted", - "text": "سلام علامت Aمثبت مفهومش چیست؟", - "answer_count": 5, - "sender": "مصطفی صنایعیان", - "created_at": "15 اردیبهشت 1402" - }, - { - "id": 3553714, - "status": "accepted", - "text": "سینه مرغ بسته ای ۹۵ تومن یا کیلویی ۹۵ تومن؟؟", - "answer_count": 6, - "sender": "ملیکا شهبازی", - "created_at": "22 خرداد 1401" - }, - { - "id": 3358273, - "status": "accepted", - "text": "استخوان دارد؟\n", - "answer_count": 7, - "sender": "نسرین صفاوردی", - "created_at": "7 اردیبهشت 1401" - } - ], - "digify_touchpoint": "" - }, - "data_layer": { - "event": "eec.productDetail", - "ecommerce": { - "detail": { - "actionField": { - "list": "category-گوشت مرغ" - }, - "products": [ - { - "brand": "مهیا پروتئین", - "category": "[FF,گوشت مرغ]", - "metric6": 2173, - "dimension2": 0, - "dimension6": 0, - "dimension7": "none", - "dimension9": 4.3, - "dimension11": 0, - "dimension20": "out_of_stock", - "item_category2": "مواد پروتئینی و تخم مرغ", - "item_category3": "", - "item_category4": "", - "item_category5": "", - "name": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "id": 792148, - "metric8": 0, - "dimension3": "marketplace", - "dimension15": 0, - "metric15": 0, - "metric11": 775, - "metric12": 600 - } - ] - } - } - }, - "seo": { - "title": "قیمت و خرید جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "description": "خرید اینترنتی جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم به همراه مقایسه، بررسی مشخصات و لیست قیمت امروز در فروشگاه اینترنتی دیجی‌کالا", - "twitter_card": { - "title": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "image": "https://dkstatics-public.digikala.com/digikala-products/3d70b4ef3f0647dc67a7ae086755afdd21b9ff2b_1675085791.jpg?x-oss-process=image/resize,m_lfit,h_350,w_350/quality,q_60", - "price": 0, - "description": "خرید اینترنتی جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم به همراه مقایسه، بررسی مشخصات و لیست قیمت امروز در فروشگاه اینترنتی دیجی‌کالا" - }, - "open_graph": { - "title": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "url": "https://www.digikala.com/product/dkp-792148/جوجه-کباب-ران-مرغ-مهیا-پروتئین-09-کیلوگرم", - "image": "https://dkstatics-public.digikala.com/digikala-products/3d70b4ef3f0647dc67a7ae086755afdd21b9ff2b_1675085791.jpg?x-oss-process=image/resize,m_lfit,h_350,w_350/quality,q_60", - "availability": "out of stock", - "type": "product", - "site": "دیجی‌کالا", - "price": 0 - }, - "header": { - "title": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "description": "خرید اینترنتی جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم به همراه مقایسه، بررسی مشخصات و لیست قیمت امروز در فروشگاه اینترنتی دیجی‌کالا", - "canonical_url": "https://www.digikala.com/fresh/product/dkp-792148/%D8%AC%D9%88%D8%AC%D9%87-%DA%A9%D8%A8%D8%A7%D8%A8-%D8%B1%D8%A7%D9%86-%D9%85%D8%B1%D8%BA-%D9%85%D9%87%DB%8C%D8%A7-%D9%BE%D8%B1%D9%88%D8%AA%D8%A6%DB%8C%D9%86-09-%DA%A9%DB%8C%D9%84%D9%88%DA%AF%D8%B1%D9%85" - }, - "markup_schema": [ - { - "@type": "Product", - "@context": "https://www.schema.org", - "name": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم", - "alternateName": "Mahya Protein Chicken Barbecue Drumstick - 0.9 Kg", - "images": [ - "https://dkstatics-public.digikala.com/digikala-products/1f85d2dab3ceb24b47d37cd1b6d4f21a09058417_1675085790.jpg?x-oss-process=image/resize,h_1600/quality,q_80" - ], - "description": "خرید اینترنتی جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم به همراه مقایسه، بررسی مشخصات و لیست قیمت امروز در فروشگاه اینترنتی دیجی‌کالا", - "mpn": 792148, - "sku": 792148, - "category": "https://www.digikala.com/search/category-chicken/", - "brand": { - "@type": "Brand", - "name": "مهیا پروتئین", - "url": "https://www.digikala.com/brand/mahya-protein/", - "@id": "https://www.digikala.com/brand/mahya-protein/#brand" - }, - "aggregateRating": { - "@type": "AggregateRating", - "ratingValue": 4.2, - "reviewCount": 2179 - }, - "offers": { - "@type": "Offer", - "priceCurrency": "IRR", - "price": 1850000, - "itemCondition": "https://schema.org/NewCondition", - "availability": "https://schema.org/InStock" - }, - "review": { - "@type": "Review", - "reviewRating": { - "@type": "Rating", - "bestRating": 5, - "ratingValue": 4 - }, - "author": { - "@type": "Person", - "name": "سید زهیر مرتضوی" - }, - "datePublished": "2024-09-17", - "reviewBody": "یه کم بو گرفته بود", - "name": "" - } - }, - [ - { - "@context": "https://schema.org", - "@type": "BreadcrumbList", - "itemListElement": [ - { - "@type": "ListItem", - "position": 1, - "name": "سوپرمارکت", - "item": { - "@type": "Corporation", - "@id": "//#corporation" - } - }, - { - "@type": "ListItem", - "position": 2, - "name": "مواد پروتئینی و تخم مرغ", - "item": "https://www.digikala.com/freshmain/protein-foods/" - }, - { - "@type": "ListItem", - "position": 3, - "name": "گوشت مرغ", - "item": "https://www.digikala.com/freshsearch/category-chicken/" - }, - { - "@type": "ListItem", - "position": 4, - "name": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم" - } - ] - }, - { - "@context": "https://schema.org", - "@type": "BreadcrumbList", - "itemListElement": [ - { - "@type": "ListItem", - "position": 1, - "name": "مهیا پروتئین", - "item": { - "@type": "Brand", - "@id": "https://www.digikala.com/brand/mahya-protein/#brand" - } - }, - { - "@type": "ListItem", - "position": 2, - "name": "گوشت مرغ مهیا پروتئین", - "item": "https://www.digikala.com/search/category-chicken/mahya-protein/" - }, - { - "@type": "ListItem", - "position": 3, - "name": "جوجه کباب ران مرغ مهیا پروتئین - 0.9 کیلوگرم" - } - ] - } - ] - ] - }, - "promotion_banner": { - "dkjet_promotion": { - "mobile_banner": "https://dkstatics-public.digikala.com/digikala-static/e532944f277b28a38b3cfbf5f70e02f678145da5_1722682800.jpg", - "desktop_banner": "https://dkstatics-public.digikala.com/digikala-static/b37b8af7fc36e9bf8e673fc09a29dfebebb7634b_1722682228.jpg", - "url": "https://www.digikalajet.com/?utm_source=digikala&utm_medium=pdp&utm_campaign=Paid" - } - }, - "bigdata_tracker_data": { - "page_name": "product", - "page_info": { - "product_id": 792148 - } - } - } -} \ No newline at end of file