|
@ -14,55 +14,52 @@ from bs4 import BeautifulSoup |
|
|
def metaversemarket_description_parser(soup): |
|
|
def metaversemarket_description_parser(soup): |
|
|
# Fields to be parsed |
|
|
# Fields to be parsed |
|
|
|
|
|
|
|
|
name = "-1" # 0 Product_Name |
|
|
|
|
|
describe = "-1" # 1 Product_Description |
|
|
|
|
|
lastSeen = "-1" # 2 Product_LastViewDate |
|
|
|
|
|
CVE = "-1" # 4 Product_CVE_Classification (Common Vulnerabilities and Exposures) |
|
|
|
|
|
MS = "-1" # 5 Product_MS_Classification (Microsoft Security) |
|
|
|
|
|
review = "-1" # 6 Product_Number_Of_Reviews |
|
|
|
|
|
category = "-1" # 7 Product_Category |
|
|
|
|
|
shipFrom = "-1" # 8 Product_ShippedFrom |
|
|
|
|
|
shipTo = "-1" # 9 Product_ShippedTo |
|
|
|
|
|
left = "-1" # 10 Product_QuantityLeft |
|
|
|
|
|
escrow = "-1" # 11 Vendor_Warranty |
|
|
|
|
|
terms = "-1" # 12 Vendor_TermsAndConditions |
|
|
|
|
|
vendor = "-1" # 13 Vendor_Name |
|
|
|
|
|
sold = "-1" # 14 Product_QuantitySold |
|
|
|
|
|
addDate = "-1" # 15 Product_AddedDate |
|
|
|
|
|
BTC = "-1" # 18 Product_BTC_SellingPrice |
|
|
|
|
|
USD = "-1" # 19 Product_USD_SellingPrice |
|
|
|
|
|
rating = "-1" # 20 Vendor_Rating |
|
|
|
|
|
success = "-1" # 21 Vendor_Successful_Transactions |
|
|
|
|
|
EURO = "-1" # 22 Product_EURO_SellingPrice |
|
|
|
|
|
|
|
|
vendor = "-1" # 0 *Vendor_Name |
|
|
|
|
|
success = "-1" # 1 Vendor_Successful_Transactions |
|
|
|
|
|
rating_vendor = "-1" # 2 Vendor_Rating |
|
|
|
|
|
name = "-1" # 3 *Product_Name |
|
|
|
|
|
describe = "-1" # 4 Product_Description |
|
|
|
|
|
CVE = "-1" # 5 Product_CVE_Classification (Common Vulnerabilities and Exposures) |
|
|
|
|
|
MS = "-1" # 6 Product_MS_Classification (Microsoft Security) |
|
|
|
|
|
category = "-1" # 7 Product_Category |
|
|
|
|
|
views = "-1" # 8 Product_Number_Of_Views |
|
|
|
|
|
reviews = "-1" # 9 Product_Number_Of_Reviews |
|
|
|
|
|
rating_item = "-1" # 10 Product_Rating |
|
|
|
|
|
addDate = "-1" # 11 Product_AddedDate |
|
|
|
|
|
BTC = "-1" # 12 Product_BTC_SellingPrice |
|
|
|
|
|
USD = "-1" # 13 Product_USD_SellingPrice |
|
|
|
|
|
EURO = "-1" # 14 Product_EURO_SellingPrice |
|
|
|
|
|
sold = "-1" # 15 Product_QuantitySold |
|
|
|
|
|
left = "-1" # 16 Product_QuantityLeft |
|
|
|
|
|
shipFrom = "-1" # 17 Product_ShippedFrom |
|
|
|
|
|
shipTo = "-1" # 18 Product_ShippedTo |
|
|
|
|
|
image = "-1" # 19 Product_Image |
|
|
|
|
|
vendor_image = "-1" # 20 Vendor_Image |
|
|
|
|
|
|
|
|
# Finding Product Name |
|
|
# Finding Product Name |
|
|
name = soup.find('div', {'class': "panel-heading"}).text.strip |
|
|
|
|
|
|
|
|
name = soup.find('div', {'class': "panel-heading"}).text |
|
|
|
|
|
name = cleanString(name.strip()) |
|
|
|
|
|
|
|
|
# Finding Vendor |
|
|
# Finding Vendor |
|
|
temp = soup.findAll('div', {'class': "col-xs-12 col-sm-6 mt-5"}) |
|
|
temp = soup.findAll('div', {'class': "col-xs-12 col-sm-6 mt-5"}) |
|
|
temp = temp[1].findAll('span') |
|
|
temp = temp[1].findAll('span') |
|
|
temp = temp[1].find('b').text |
|
|
|
|
|
name = temp.replace("@", "") |
|
|
|
|
|
|
|
|
vendor = temp[1].find('b').text |
|
|
|
|
|
vendor = cleanString(vendor.strip()) |
|
|
|
|
|
|
|
|
# Finding Product Reviews |
|
|
# Finding Product Reviews |
|
|
review = soup.find('span', {'class': "badge bg-success fs-12px"}).text.strip() |
|
|
|
|
|
|
|
|
reviews = soup.find('span', {'class': "badge bg-success fs-12px"}).text.strip() |
|
|
|
|
|
|
|
|
# Finding Successful Transactions |
|
|
# Finding Successful Transactions |
|
|
# NA |
|
|
# NA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Finding Prices |
|
|
# Finding Prices |
|
|
USD = soup.find('h3', {'class': "mb-2"}).text() |
|
|
|
|
|
|
|
|
USD = soup.find('h3', {'class': "mb-2"}).text |
|
|
USD = USD.replace("Price: $", "").strip() |
|
|
USD = USD.replace("Price: $", "").strip() |
|
|
|
|
|
|
|
|
# Finding Escrow |
|
|
|
|
|
escrow = soup.find('div', {'class': "alert alert-info text-center fw-bold"}).text |
|
|
|
|
|
escrow = escrow.replace('You are protected by ', "").strip() |
|
|
|
|
|
|
|
|
|
|
|
# Finding the Product Category |
|
|
# Finding the Product Category |
|
|
temp = soup.select('div[class="mt-2"]') |
|
|
|
|
|
temp = temp[0].findAll('span') |
|
|
|
|
|
category = temp[1].text.strip() |
|
|
|
|
|
|
|
|
temp = soup.select('div[class="mt-2"]')[1].text |
|
|
|
|
|
temp = temp.replace("Category:", "") |
|
|
|
|
|
category = temp.strip() |
|
|
|
|
|
|
|
|
# Finding the Product Quantity Available |
|
|
# Finding the Product Quantity Available |
|
|
# temp = soup.find('em', {'class': "icon ni ni-layers-fill"}).parent.parent.parent |
|
|
# temp = soup.find('em', {'class': "icon ni ni-layers-fill"}).parent.parent.parent |
|
@ -78,8 +75,8 @@ def metaversemarket_description_parser(soup): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Finding Shipment Information (Origin) |
|
|
# Finding Shipment Information (Origin) |
|
|
temp = soup.findAll('div', {'class': "alert alert-info"}) |
|
|
|
|
|
temp = temp[1].text.split("to") |
|
|
|
|
|
|
|
|
temp = soup.find('div', {'class': "alert alert-info"}).text |
|
|
|
|
|
temp = temp.split("to") |
|
|
shipFrom = temp[0].replace("Shipping from ", "").strip() |
|
|
shipFrom = temp[0].replace("Shipping from ", "").strip() |
|
|
|
|
|
|
|
|
# Finding Shipment Information (Destination) |
|
|
# Finding Shipment Information (Destination) |
|
@ -123,8 +120,8 @@ def metaversemarket_description_parser(soup): |
|
|
MS = MS.replace('\n', '') |
|
|
MS = MS.replace('\n', '') |
|
|
|
|
|
|
|
|
# Populating the final variable (this should be a list with all fields scraped) |
|
|
# Populating the final variable (this should be a list with all fields scraped) |
|
|
row = (name, describe, lastSeen, CVE, MS, review, category, shipFrom, shipTo, left, escrow, terms, vendor, |
|
|
|
|
|
sold, addDate, BTC, USD, rating, success, EURO) |
|
|
|
|
|
|
|
|
row = (vendor, rating_vendor, success, name, describe, CVE, MS, category, views, reviews, rating_item, addDate, |
|
|
|
|
|
BTC, USD, EURO, sold, left, shipFrom, shipTo, image, vendor_image) |
|
|
|
|
|
|
|
|
# Sending the results |
|
|
# Sending the results |
|
|
return row |
|
|
return row |
|
@ -136,29 +133,30 @@ def metaversemarket_description_parser(soup): |
|
|
# 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 metaversemarket_listing_parser(soup): |
|
|
def metaversemarket_listing_parser(soup): |
|
|
# Fields to be parsed |
|
|
# Fields to be parsed |
|
|
nm = 0 # Total_Products (Should be Integer) |
|
|
|
|
|
mktName = "DarkFox" # 0 Marketplace_Name |
|
|
|
|
|
name = [] # 1 Product_Name |
|
|
|
|
|
CVE = [] # 2 Product_CVE_Classification (Common Vulnerabilities and Exposures) |
|
|
|
|
|
MS = [] # 3 Product_MS_Classification (Microsoft Security) |
|
|
|
|
|
category = [] # 4 Product_Category |
|
|
|
|
|
describe = [] # 5 Product_Description |
|
|
|
|
|
escrow = [] # 6 Vendor_Warranty |
|
|
|
|
|
views = [] # 7 Product_Number_Of_Views |
|
|
|
|
|
reviews = [] # 8 Product_Number_Of_Reviews |
|
|
|
|
|
addDate = [] # 9 Product_AddDate |
|
|
|
|
|
lastSeen = [] # 10 Product_LastViewDate |
|
|
|
|
|
BTC = [] # 11 Product_BTC_SellingPrice |
|
|
|
|
|
USD = [] # 12 Product_USD_SellingPrice |
|
|
|
|
|
EURO = [] # 13 Product_EURO_SellingPrice |
|
|
|
|
|
sold = [] # 14 Product_QuantitySold |
|
|
|
|
|
qLeft = [] # 15 Product_QuantityLeft |
|
|
|
|
|
shipFrom = [] # 16 Product_ShippedFrom |
|
|
|
|
|
shipTo = [] # 17 Product_ShippedTo |
|
|
|
|
|
vendor = [] # 18 Vendor |
|
|
|
|
|
rating = [] # 19 Vendor_Rating |
|
|
|
|
|
success = [] # 20 Vendor_Successful_Transactions |
|
|
|
|
|
href = [] # 23 Product_Links (Urls) |
|
|
|
|
|
|
|
|
nm = 0 # *Total_Products (Should be Integer) |
|
|
|
|
|
mktName = "MetaVerseMarket" # 0 *Marketplace_Name |
|
|
|
|
|
vendor = [] # 1 *Vendor y |
|
|
|
|
|
rating_vendor = [] # 2 Vendor_Rating |
|
|
|
|
|
success = [] # 3 Vendor_Successful_Transactions |
|
|
|
|
|
name = [] # 4 *Product_Name y |
|
|
|
|
|
CVE = [] # 5 Product_CVE_Classification (Common Vulnerabilities and Exposures) dont worry about this |
|
|
|
|
|
MS = [] # 6 Product_MS_Classification (Microsoft Security) dont worry about this |
|
|
|
|
|
category = [] # 7 Product_Category y |
|
|
|
|
|
describe = [] # 8 Product_Description |
|
|
|
|
|
views = [] # 9 Product_Number_Of_Views |
|
|
|
|
|
reviews = [] # 10 Product_Number_Of_Reviews |
|
|
|
|
|
rating_item = [] # 11 Product_Rating |
|
|
|
|
|
addDate = [] # 12 Product_AddDate |
|
|
|
|
|
BTC = [] # 13 Product_BTC_SellingPrice |
|
|
|
|
|
USD = [] # 14 Product_USD_SellingPrice y |
|
|
|
|
|
EURO = [] # 15 Product_EURO_SellingPrice |
|
|
|
|
|
sold = [] # 16 Product_QuantitySold |
|
|
|
|
|
qLeft = [] # 17 Product_QuantityLeft |
|
|
|
|
|
shipFrom = [] # 18 Product_ShippedFrom |
|
|
|
|
|
shipTo = [] # 19 Product_ShippedTo |
|
|
|
|
|
image = [] # 20 Product_Image |
|
|
|
|
|
image_vendor = [] # 21 Vendor_Image |
|
|
|
|
|
href = [] # 22 Product_Links |
|
|
|
|
|
|
|
|
listing = soup.findAll('div', {"class": "col-12 col-sm-4 col-xl-3 product_item_col p-1"}) |
|
|
listing = soup.findAll('div', {"class": "col-12 col-sm-4 col-xl-3 product_item_col p-1"}) |
|
|
|
|
|
|
|
@ -175,11 +173,7 @@ def metaversemarket_listing_parser(soup): |
|
|
|
|
|
|
|
|
# Finding the Product |
|
|
# Finding the Product |
|
|
product = bae[1].find('span', {"class": "text-primary"}).text |
|
|
product = bae[1].find('span', {"class": "text-primary"}).text |
|
|
product = product.replace('\n', ' ') |
|
|
|
|
|
product = product.replace(",", "") |
|
|
|
|
|
product = product.replace("...", "") |
|
|
|
|
|
product = product.strip() |
|
|
|
|
|
name.append(product) |
|
|
|
|
|
|
|
|
name.append(cleanString(product.strip())) |
|
|
|
|
|
|
|
|
# Finding Prices |
|
|
# Finding Prices |
|
|
price = a.find('strong').text |
|
|
price = a.find('strong').text |
|
@ -191,20 +185,18 @@ def metaversemarket_listing_parser(soup): |
|
|
# Finding the Vendor |
|
|
# Finding the Vendor |
|
|
temp = a.find('div', {'class': "mt-1 fs-12px"}) |
|
|
temp = a.find('div', {'class': "mt-1 fs-12px"}) |
|
|
temp = temp.findAll('span') |
|
|
temp = temp.findAll('span') |
|
|
temp = temp[1].find('b').text |
|
|
|
|
|
vendor_name = temp.replace("@", "").strip() |
|
|
|
|
|
vendor.append(vendor_name) |
|
|
|
|
|
|
|
|
vendor_name = temp[1].find('b').text |
|
|
|
|
|
vendor.append(cleanString(vendor_name.strip())) |
|
|
|
|
|
|
|
|
# Finding the Category |
|
|
# Finding the Category |
|
|
cat = a.select_one('div[class="fs-12px"]') |
|
|
cat = a.select_one('div[class="fs-12px"]') |
|
|
cat = cat.findAll('span')[1].text |
|
|
cat = cat.findAll('span')[1].text |
|
|
cat = cat.text |
|
|
|
|
|
cat = cat.strip() |
|
|
cat = cat.strip() |
|
|
category.append(cat) |
|
|
category.append(cat) |
|
|
|
|
|
|
|
|
badge = a.findAll('span', {'class': "badge bg-success"}) |
|
|
|
|
|
|
|
|
badge = a.find('span', {'class': "badge bg-success"}) |
|
|
# Finding Number Sold and Quantity Left |
|
|
# Finding Number Sold and Quantity Left |
|
|
temp = badge[1].text |
|
|
|
|
|
|
|
|
temp = badge.text |
|
|
temp = temp.split("/") |
|
|
temp = temp.split("/") |
|
|
num = temp[0] |
|
|
num = temp[0] |
|
|
num = num.strip() |
|
|
num = num.strip() |
|
@ -226,11 +218,7 @@ def metaversemarket_listing_parser(soup): |
|
|
description = a.find('p', {'class': "alert alert-light text-ssbold p-1"}).text |
|
|
description = a.find('p', {'class': "alert alert-light text-ssbold p-1"}).text |
|
|
description = description.replace("\n", " ") |
|
|
description = description.replace("\n", " ") |
|
|
description = description.strip() |
|
|
description = description.strip() |
|
|
describe.append(description) |
|
|
|
|
|
|
|
|
|
|
|
# Finding Escrow |
|
|
|
|
|
es = a.find('span', {'class': "fw-bold"}).text.strip() |
|
|
|
|
|
escrow.append(es) |
|
|
|
|
|
|
|
|
describe.append(cleanString(description)) |
|
|
|
|
|
|
|
|
# Finding Number of Views |
|
|
# Finding Number of Views |
|
|
view = a.find('span', {'class': "badge bg-primary"}).text.strip() |
|
|
view = a.find('span', {'class': "badge bg-primary"}).text.strip() |
|
@ -239,11 +227,11 @@ def metaversemarket_listing_parser(soup): |
|
|
# Find where ships from |
|
|
# Find where ships from |
|
|
ships = a.find('div', {'class': "alert alert-info item_alert fs-12px p-1"}) |
|
|
ships = a.find('div', {'class': "alert alert-info item_alert fs-12px p-1"}) |
|
|
ships = ships.findAll('b') |
|
|
ships = ships.findAll('b') |
|
|
sFrom = ships[0].text.strips() |
|
|
|
|
|
|
|
|
sFrom = ships[0].text.strip() |
|
|
shipFrom.append(sFrom) |
|
|
shipFrom.append(sFrom) |
|
|
|
|
|
|
|
|
# Find where it ships to |
|
|
# Find where it ships to |
|
|
sTo = ships[1].text.strips() |
|
|
|
|
|
|
|
|
sTo = ships[1].text.strip() |
|
|
shipTo.append(sTo) |
|
|
shipTo.append(sTo) |
|
|
|
|
|
|
|
|
# Searching for CVE and MS categories |
|
|
# Searching for CVE and MS categories |
|
@ -274,8 +262,8 @@ def metaversemarket_listing_parser(soup): |
|
|
MS.append(MSValue) |
|
|
MS.append(MSValue) |
|
|
|
|
|
|
|
|
# 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, name, CVE, MS, category, describe, escrow, views, reviews, addDate, lastSeen, |
|
|
|
|
|
BTC, USD, EURO, qLeft, shipFrom, shipTo, vendor, rating, success, sold, 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, image, image_vendor) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# called by the crawler to get description links on a listing page |
|
|
# called by the crawler to get description links on a listing page |
|
|