|
|
@ -1,3 +1,5 @@ |
|
|
|
__author__ = 'DarkWeb' |
|
|
|
|
|
|
|
# Here, we are importing the auxiliary functions to clean or convert data |
|
|
|
from MarketPlaces.Utilities.utilities import * |
|
|
|
|
|
|
@ -44,21 +46,23 @@ def darkbazar_description_parser(soup): |
|
|
|
vendor = divmb[1].find('a').text.strip() |
|
|
|
|
|
|
|
# Finding Vendor Rating |
|
|
|
rating = soup.find('div', {'class': ""}).text |
|
|
|
rating = rating.replace("Vendor's Review : ", "") |
|
|
|
rating = rating.strip() |
|
|
|
temp = soup.find('div', {'class': ""}).text |
|
|
|
temp = temp.split('(') |
|
|
|
rating = temp[0].replace("Vendor's Review : ", "") |
|
|
|
rating = rating.replace("%", "") |
|
|
|
rating_vendor = rating.strip() |
|
|
|
|
|
|
|
# Finding the Product Rating and Number of Product Reviews |
|
|
|
reviews = temp[2].replace(" review)", "") |
|
|
|
reviews = reviews.strip() |
|
|
|
|
|
|
|
# Finding Successful Transactions |
|
|
|
success = divmb[3].text |
|
|
|
success = success.replace("Level:", "") |
|
|
|
success = success.strip() |
|
|
|
temp = temp[1].split(")") |
|
|
|
rating = temp[1].replace("Product Review : ", "") |
|
|
|
rating = rating.replace("%", "") |
|
|
|
rating_item = rating.strip() |
|
|
|
|
|
|
|
# Finding Prices |
|
|
|
USD = soup.find('div', {'class': "h3 text - primary"}).text.strip() |
|
|
|
|
|
|
|
|
|
|
|
# Finding Escrow |
|
|
|
escrow = divmb[5].find('span', {'class': "badge badge-danger"}).text.strip() |
|
|
|
USD = soup.find('div', {'class': "h3 text-primary"}).text.strip() |
|
|
|
|
|
|
|
# Finding the Product Category |
|
|
|
pmb = soup.findAll('p', {'class': "mb-1"}) |
|
|
@ -78,7 +82,6 @@ def darkbazar_description_parser(soup): |
|
|
|
sold = sold.replace("sold", "") |
|
|
|
sold = sold.strip() |
|
|
|
|
|
|
|
|
|
|
|
# Finding Shipment Information (Origin) |
|
|
|
pmb[0].text |
|
|
|
shipFrom = shipFrom.replace("Ships from: ", "").strip() |
|
|
@ -91,13 +94,6 @@ def darkbazar_description_parser(soup): |
|
|
|
cardbody = soup.findAll('div', {'class': "card-body"}) |
|
|
|
describe = cardbody[1].text.strip() |
|
|
|
|
|
|
|
# Finding the Number of Product Reviews |
|
|
|
reviews = reviews.find('div', {'class': "product-rating"}).text |
|
|
|
reviews = reviews.replace("(", "") |
|
|
|
reviews = reviews.replace(" review)", "") |
|
|
|
reviews = reviews.strip() |
|
|
|
|
|
|
|
|
|
|
|
# Searching for CVE and MS categories |
|
|
|
cve = soup.findAll(text=re.compile('CVE-\d{4}-\d{4}')) |
|
|
|
if cve: |
|
|
@ -117,8 +113,8 @@ def darkbazar_description_parser(soup): |
|
|
|
MS = MS.replace('\n', '') |
|
|
|
|
|
|
|
# Populating the final variable (this should be a list with all fields scraped) |
|
|
|
row = (name, describe, CVE, MS, review, category, shipFrom, shipTo, left, escrow, 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) |
|
|
|
|
|
|
|
# Sending the results |
|
|
|
return row |
|
|
@ -129,30 +125,30 @@ def darkbazar_description_parser(soup): |
|
|
|
# @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 |
|
|
|
def darkbazar_listing_parser(soup): |
|
|
|
|
|
|
|
# Fields to be parsed |
|
|
|
nm = 0 # Total_Products (Should be Integer) |
|
|
|
mktName = "DarkBazar" # 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 = "DarkBazar" # 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 |
|
|
|
href = [] # 20 Product_Links |
|
|
|
|
|
|
|
listing = soup.findAll('div', {"id": "itembox"}) |
|
|
|
|
|
|
@ -194,13 +190,21 @@ def darkbazar_listing_parser(soup): |
|
|
|
cat = cat.strip() |
|
|
|
category.append(cat) |
|
|
|
|
|
|
|
# Finding Number Sold and Quantity Left |
|
|
|
span = lb[1].findAll("span") |
|
|
|
num = span[-1].text |
|
|
|
span = lb[0].findAll("span") |
|
|
|
|
|
|
|
# Finding Number of Views |
|
|
|
num = span[0].text |
|
|
|
num = num.replace("views:", "") |
|
|
|
num = num.strip() |
|
|
|
sold.append(num) |
|
|
|
|
|
|
|
# Finding Number Sold |
|
|
|
num = span[2].text |
|
|
|
num = num.replace("Sold:", "") |
|
|
|
num = num.strip() |
|
|
|
category.append(num) |
|
|
|
sold.append(num) |
|
|
|
|
|
|
|
# Finding Quantity Left |
|
|
|
quant = span[1].text |
|
|
|
quant = quant.replace("stock:", "") |
|
|
|
quant = quant.strip() |
|
|
@ -235,8 +239,8 @@ def darkbazar_listing_parser(soup): |
|
|
|
MS.append(MSValue) |
|
|
|
|
|
|
|
# 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) |
|
|
|
|
|
|
|
|
|
|
|
# called by the crawler to get description links on a listing page |
|
|
@ -258,7 +262,6 @@ def darkbazar_links_parser(soup): |
|
|
|
|
|
|
|
# Adding the url to the list of urls |
|
|
|
link = bae[0].get('href') |
|
|
|
link = cleanLink(link) |
|
|
|
href.append(link) |
|
|
|
|
|
|
|
return href |