From ab312868e2b52a90c2d922fbfc71afc95f057782 Mon Sep 17 00:00:00 2001 From: "shariar@raenabeauty.com" Date: Wed, 7 Feb 2024 09:54:57 +0400 Subject: [PATCH] FB Marketplace crawler --- fb_marketplace/fb_marketplace_product_info.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fb_marketplace/fb_marketplace_product_info.py b/fb_marketplace/fb_marketplace_product_info.py index bfee87a..86d15d0 100644 --- a/fb_marketplace/fb_marketplace_product_info.py +++ b/fb_marketplace/fb_marketplace_product_info.py @@ -72,7 +72,7 @@ class FbMarketplaceProductInfo: def getProductInfo(self, data): - name = data[0] + name = str(data[0]).replace("'","") price = data[1] url = data[2] city = data[3].replace(',','') @@ -89,6 +89,7 @@ class FbMarketplaceProductInfo: if name == "" or name is None: name = self.driver.find_element(By.XPATH,'/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div/div/div/div[1]/div[2]/div/div[2]/div/div[1]/div[1]/div[1]/div[1]/h1/span').text + name = name.replace("'","") @@ -118,17 +119,21 @@ class FbMarketplaceProductInfo: try: description = self.driver.find_element(By.CSS_SELECTOR, ".xz9dl7a.x4uap5.xsag5q8.xkhd6sd.x126k92a").find_element(By.CSS_SELECTOR, ".x193iq5w.xeuugli.x13faqbe.x1vvkbs.xlh3980.xvmahel.x1n0sxbx.x1lliihq.x1s928wv.xhkezso.x1gmr53x.x1cpjm7i.x1fgarty.x1943h6x.x4zkp8e.x3x7a5m.x6prxxf.xvq8zen.xo1l8bm.xzsf02u").text + description = description.replace("'","") except: description = self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div/div/div/div[1]/div[2]/div/div[2]/div/div[1]/div[1]/div[5]/div[2]/div/div[1]/div/span").text + description = description.replace("'", "") except: pass try: seller_name = self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div/div/div/div[1]/div[2]/div/div[2]/div/div[1]/div[1]/div[2]/div/div/div[2]/div[1]/div/div/div/div/div[2]/div/div/div/div/span/span/div/div/a/span").text + seller_name = seller_name.replace("'", "") except: try: seller_name = self.driver.find_element(By.XPATH, '/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div/div/div/div[1]/div[2]/div/div[2]/div/div[1]/div[1]/div[6]/div/div[2]/div[1]/div/div/div/div/div[2]/div/div/div/div/span/span/div/div/a/span').text + seller_name = seller_name.replace("'", "") except: pass pass