|
@ -4,7 +4,7 @@ __author__ = 'DarkWeb' |
|
|
from MarketPlaces.Utilities.utilities import * |
|
|
from MarketPlaces.Utilities.utilities import * |
|
|
|
|
|
|
|
|
# Here, we are importing BeautifulSoup to search through the HTML tree |
|
|
# Here, we are importing BeautifulSoup to search through the HTML tree |
|
|
from bs4 import BeautifulSoup, Tag |
|
|
|
|
|
|
|
|
from bs4 import BeautifulSoup, ResultSet, Tag |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#parses description pages, so takes html pages of description pages using soup object, and parses it for info it needs |
|
|
#parses description pages, so takes html pages of description pages using soup object, and parses it for info it needs |
|
@ -40,7 +40,7 @@ def digitalThriftShop_description_parser(soup: Tag): |
|
|
product_name = soup.find("h1", {"class": "product_title entry-title"}).text |
|
|
product_name = soup.find("h1", {"class": "product_title entry-title"}).text |
|
|
name = cleanString(product_name.strip()) |
|
|
name = cleanString(product_name.strip()) |
|
|
|
|
|
|
|
|
product_description = soup.find("id", {"tab-description"}).find("p").text |
|
|
|
|
|
|
|
|
product_description = soup.find("div", {"id": "tab-description"}).find("p").text |
|
|
describe = cleanString(product_description.strip()) |
|
|
describe = cleanString(product_description.strip()) |
|
|
|
|
|
|
|
|
product_category = soup.find("span", {"class": "posted_in"}).find("a").text |
|
|
product_category = soup.find("span", {"class": "posted_in"}).find("a").text |
|
@ -52,7 +52,7 @@ def digitalThriftShop_description_parser(soup: Tag): |
|
|
reviews = product_rating.find("span", {"Class": "rating"}).text |
|
|
reviews = product_rating.find("span", {"Class": "rating"}).text |
|
|
|
|
|
|
|
|
except Exception as e: |
|
|
except Exception as e: |
|
|
raisen> <span class="n">e |
|
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
product_BTC = soup.find("div", {"id": "price-BTC"}).find("span", {"class": "priceinfo cw-noselect"}).text |
|
|
product_BTC = soup.find("div", {"id": "price-BTC"}).find("span", {"class": "priceinfo cw-noselect"}).text |
|
|
BTC = cleanString(product_BTC.strip()) |
|
|
BTC = cleanString(product_BTC.strip()) |
|
@ -74,7 +74,7 @@ def digitalThriftShop_description_parser(soup: Tag): |
|
|
#stores info it needs in different lists, these lists are returned after being organized |
|
|
#stores info it needs in different lists, these lists are returned after being organized |
|
|
#@param: soup object looking at html page of listing page |
|
|
#@param: soup object looking at html page of listing page |
|
|
#return: 'row' that contains a variety of lists that each hold info on the listing page |
|
|
#return: 'row' that contains a variety of lists that each hold info on the listing page |
|
|
def digitalThriftShop_listing_parser(soup): |
|
|
|
|
|
|
|
|
def digitalThriftShop_listing_parser(soup: Tag): |
|
|
|
|
|
|
|
|
# Fields to be parsed |
|
|
# Fields to be parsed |
|
|
nm = 0 # *Total_Products (Should be Integer) |
|
|
nm = 0 # *Total_Products (Should be Integer) |
|
@ -100,13 +100,53 @@ def digitalThriftShop_listing_parser(soup): |
|
|
shipTo = [] # 19 Product_ShippedTo |
|
|
shipTo = [] # 19 Product_ShippedTo |
|
|
href = [] # 20 Product_Links |
|
|
href = [] # 20 Product_Links |
|
|
|
|
|
|
|
|
|
|
|
product_category = soup.find("h1", {"class": "woocommerce-products-header__title page-title"}).text |
|
|
|
|
|
|
|
|
|
|
|
products_list: ResultSet[Tag] = soup.find("ul", {"class": "products columns-5"}).find_all("li") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for product in products_list: |
|
|
|
|
|
nm += 1 |
|
|
|
|
|
vendor.append("-1") |
|
|
|
|
|
rating_vendor.append("-1") |
|
|
|
|
|
success.append("-1") |
|
|
|
|
|
|
|
|
|
|
|
product_name = product.find("h2", {"class": "woocommerce-loop-product__title"}).text |
|
|
|
|
|
name.append(cleanString(product_name.strip())) |
|
|
|
|
|
|
|
|
|
|
|
CVE.append("-1") |
|
|
|
|
|
MS.append("-1") |
|
|
|
|
|
category.append(cleanString(product_category.strip())) |
|
|
|
|
|
describe.append("-1") |
|
|
|
|
|
views.append("-1") |
|
|
|
|
|
reviews.append("-1") |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
product_rating = product.find("div", {"class": "star-rating"}).find("strong", {"class": "rating"}).text |
|
|
|
|
|
rating_item.append(cleanString(product_rating.strip())) |
|
|
|
|
|
except: |
|
|
|
|
|
rating_item.append("-1") |
|
|
|
|
|
|
|
|
|
|
|
addDate.append("-1") |
|
|
|
|
|
BTC.append("-1") |
|
|
|
|
|
|
|
|
|
|
|
product_USD = product.find("span", {"class": "price"}).text |
|
|
|
|
|
USD.append(product_USD.replace("$", "").strip()) |
|
|
|
|
|
|
|
|
|
|
|
EURO.append("-1") |
|
|
|
|
|
sold.append("-1") |
|
|
|
|
|
qLeft.append("-1") |
|
|
|
|
|
shipFrom.append("-1") |
|
|
|
|
|
shipTo.append("-1") |
|
|
|
|
|
|
|
|
|
|
|
product_href = product.find("a", {"class": "woocommerce-LoopProduct-link woocommerce-loop-product__link"}).get("href") |
|
|
|
|
|
href.append(cleanString(product_href.strip())) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Populate the final variable (this should be a list with all fields scraped) |
|
|
# Populate the final variable (this should be a list with all fields scraped) |
|
|
# return organizeProducts(mktName, nm, vendor, rating_vendor, success, name, CVE, MS, category, describe, views, |
|
|
|
|
|
# reviews, rating_item, addDate, BTC, USD, EURO, sold, qLeft, shipFrom, shipTo, href) |
|
|
|
|
|
|
|
|
return organizeProducts(mktName, nm, vendor, rating_vendor, success, name, CVE, MS, category, describe, views, |
|
|
|
|
|
reviews, rating_item, addDate, BTC, USD, EURO, sold, qLeft, shipFrom, shipTo, href) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#called by the crawler to get description links on a listing page |
|
|
#called by the crawler to get description links on a listing page |
|
|