async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting xtmobile product " + link) soup = BeautifulSoup(r.text, 'html.parser') sale_price_tag = soup.find("span", {"itemprop": "price"}) original_price_tag = soup.find("span", {"class": "price_old"}) sale_price = human_price_to_integer(sale_price_tag['content']) original_price = sale_price if original_price_tag: original_price = human_price_to_integer(original_price_tag.text) return Product(original_price=original_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting Antien product " + link) soup = BeautifulSoup(r.text, 'html.parser') pricing_tag = soup.find("div", {"class": "price-pro"}) original_price_tag = pricing_tag.find("strong") sale_price_tag = pricing_tag.find("strong") original_price = human_price_to_integer(original_price_tag.text) sale_price = human_price_to_integer( sale_price_tag. text if sale_price_tag is not None else original_price_tag.text) return Product(original_price=original_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting Hnam product " + link) soup = BeautifulSoup(r.text, 'html.parser') sale_price_tag = soup.find("input", {"class": "product-item-value-price"}) original_price_tag = soup.find( "input", {"class": "product-item-value-price-base"}) sale_price = human_price_to_integer(sale_price_tag['value']) original_price = human_price_to_integer(original_price_tag['value']) if original_price == 0: original_price = sale_price return Product(original_price=original_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting Halo product " + link) soup = BeautifulSoup(r.text, 'html.parser') sale_price_tag = soup.find("div", {"class": "product-price"}) if sale_price_tag: sale_price = human_price_to_integer(sale_price_tag.text) return Product(sale_price, sale_price) sale_price_tag = soup.find("div", {"class": "product-price-new"}) original_price_tag = soup.find("div", {"class": "product-price-old"}) sale_price = human_price_to_integer(sale_price_tag.text) original_price = human_price_to_integer(original_price_tag.text) return Product(original_price=original_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting BaoChau product " + link) soup = BeautifulSoup(r.text, 'html.parser') pricing_tag = soup.find("div", {"class": "price_and_no"}) p_tags = pricing_tag.find_all("p") current_price = human_price_to_integer(p_tags[0].strong.text) origianl_price_tag = p_tags[1].find( "del") if len(p_tags) >= 2 else None original_price = current_price if origianl_price_tag: original_price = human_price_to_integer(origianl_price_tag.text) return Product(original_price=original_price, sale_price=current_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting Bach Long product " + link) soup = BeautifulSoup(r.text, 'html.parser') price_div = soup.find("div", {"class": "box-title-product"}) sale_price_tag = price_div.find("span", {"class": "price"}) original_price_tag = soup.find("span", {"class": "oldprice"}) original_price = 0 sale_price = 0 if original_price_tag: sale_price = human_price_to_integer(sale_price_tag.text) original_price = human_price_to_integer(original_price_tag.text) else: sale_price = human_price_to_integer(sale_price_tag.text) original_price = sale_price return Product(original_price=original_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting CTMobile product " + link) soup = BeautifulSoup(r.text, 'html.parser') pricing_div = soup.find("span", {"class": "price"}) # get first sale_price = human_price_to_integer(pricing_div.text) return Product(original_price=sale_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting HoangHa product " + link) soup = BeautifulSoup(r.text, 'html.parser') pricing_div = soup.find("p", {"class": "price current-product-price"}) sale_price_tags = pricing_div.strong original_price_tags = pricing_div.strike original_price = 0 sale_price = 0 if original_price_tags: sale_price = human_price_to_integer(sale_price_tags.text) original_price = human_price_to_integer(original_price_tags.text) else: sale_price = human_price_to_integer(sale_price_tags.text) original_price = sale_price return Product(original_price=original_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting minhtuanmobile product " + link) soup = BeautifulSoup(r.text, 'html.parser') sale_price_tags = soup.find_all("p", class_="prodetail__price mb-1") or [] original_price_tag = soup.find("p", class_="clearfix prodetail__price_orig") original_price = 0 sale_price = 0 for sale_price_tag in sale_price_tags: t = sale_price_tag.find("b", class_="price") if t: sale_price = human_price_to_integer(t.text) if original_price_tag: original_price = human_price_to_integer(original_price_tag.text) return Product(original_price=original_price, sale_price=sale_price, link=link)
def _get_price_case2(self, text, link): matcher = self.PATTERN2.search(text) if not matcher: raise Exception( "error getting Cellphone product, not found pattern. Link" + link) jsonStr = matcher.group(1).strip() if jsonStr[-1] == ';': jsonStr = jsonStr[:-1] soup = BeautifulSoup(text, 'html.parser') product_id = jsonStr sale_price_tag_id = f'product-price-{product_id}' original_price_tag_id = f'old-price-{product_id}' sale_price_tag = soup.find(id=sale_price_tag_id) original_price_tag = soup.find(id=original_price_tag_id) sale_price = human_price_to_integer(sale_price_tag.text) original_price = sale_price if original_price_tag: original_price = human_price_to_integer(original_price_tag.text) return Product(original_price=original_price, sale_price=sale_price, link=link)
async def get_price(self, link: str) -> Product: r = requests.get(link) if r.status_code not in (200, 201): raise Exception("error getting duc huy product " + link) matcher = self.PATTERN.search(r.text) if not matcher: raise Exception( "error getting Cellphone product, not found pattern. Link" + link) soup = BeautifulSoup(r.text, 'html.parser') jsonStr = matcher.group(1).strip() if jsonStr[-1] == ';': jsonStr = jsonStr[:-1] jsonStr = jsonStr.replace("'", "\"") p_arr = json.loads(jsonStr) first_pid = p_arr[0]['ID'] sale_price_tag = soup.find(id=f"sec_discounted_price_{first_pid}") sale_price = 0 if sale_price_tag: sale_price = human_price_to_integer(sale_price_tag.text) return Product(sale_price, sale_price, link)
def convert_to_price(self, text): if text == "" or "Vui lòng gọi" in text: return 0 return human_price_to_integer(text)
def convert_to_price(self, text): if text == "" or "Liên hệ" in text: return 0 return human_price_to_integer(text)