FB Marketplace crawler

This commit is contained in:
Shariar Imtiaz 2024-02-07 09:54:57 +04:00
parent 66b95374d9
commit ab312868e2
1 changed files with 6 additions and 1 deletions

View File

@ -72,7 +72,7 @@ class FbMarketplaceProductInfo:
def getProductInfo(self, data): def getProductInfo(self, data):
name = data[0] name = str(data[0]).replace("'","")
price = data[1] price = data[1]
url = data[2] url = data[2]
city = data[3].replace(',','') city = data[3].replace(',','')
@ -89,6 +89,7 @@ class FbMarketplaceProductInfo:
if name == "" or name is None: 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 = 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: 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 = 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: 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 = 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: except:
pass pass
try: 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 = 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: except:
try: 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 = 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: except:
pass pass
pass pass