|
@ -3,6 +3,7 @@ __author__ = 'DarkWeb' |
|
|
import psycopg2 |
|
|
import psycopg2 |
|
|
import traceback |
|
|
import traceback |
|
|
import configparser |
|
|
import configparser |
|
|
|
|
|
from MarketPlaces.Utilities.utilities import * |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def connectDataBase(): |
|
|
def connectDataBase(): |
|
@ -146,7 +147,7 @@ def create_marketPlace(cur, row, url): |
|
|
sql = "Insert into marketplaces (market_id, name_market, url_market, dateinserted_market) " \ |
|
|
sql = "Insert into marketplaces (market_id, name_market, url_market, dateinserted_market) " \ |
|
|
"Values (%s, %s, %s, %s)" |
|
|
"Values (%s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
recset = [marketId, row[0], url, row[21]] |
|
|
|
|
|
|
|
|
recset = [marketId, row[0], url, row[23]] |
|
|
|
|
|
|
|
|
cur.execute(sql, recset) |
|
|
cur.execute(sql, recset) |
|
|
|
|
|
|
|
@ -165,13 +166,15 @@ def create_vendor(cur, row, marketId): |
|
|
|
|
|
|
|
|
if newVendor: |
|
|
if newVendor: |
|
|
|
|
|
|
|
|
sql = "Insert into vendors (vendor_id, market_id, name_vendor, rating_vendor, successfultransactions_vendor, dateinserted_vendor) Values (%s, %s, %s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
sql = "Insert into vendors (vendor_id, market_id, name_vendor, rating_vendor, successfultransactions_vendor, image_vendor, dateinserted_vendor) " \ |
|
|
|
|
|
"Values (%s, %s, %s, %s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
recset = [vendorId, marketId, |
|
|
recset = [vendorId, marketId, |
|
|
row[1], |
|
|
row[1], |
|
|
row[2] if row[2] != '-1' else None, |
|
|
row[2] if row[2] != '-1' else None, |
|
|
row[3] if row[3] != '-1' else None, |
|
|
row[3] if row[3] != '-1' else None, |
|
|
row[21]] |
|
|
|
|
|
|
|
|
row[21] if row[21] != '-1' else None, |
|
|
|
|
|
row[23]] |
|
|
|
|
|
|
|
|
cur.execute(sql, recset) |
|
|
cur.execute(sql, recset) |
|
|
|
|
|
|
|
@ -183,24 +186,30 @@ def create_vendor(cur, row, marketId): |
|
|
|
|
|
|
|
|
recset = cur.fetchall() |
|
|
recset = cur.fetchall() |
|
|
|
|
|
|
|
|
|
|
|
#aes_decryption(recset[0][5]) trying to decrypt the image |
|
|
|
|
|
|
|
|
if (str(recset[0][3]) != str(row[2] if row[2] != '-1' else None) or # there was a change in the vendor information |
|
|
if (str(recset[0][3]) != str(row[2] if row[2] != '-1' else None) or # there was a change in the vendor information |
|
|
str(recset[0][4]) != str(row[3] if row[3] != '-1' else None)): |
|
|
|
|
|
|
|
|
str(recset[0][4]) != str(row[3] if row[3] != '-1' else None) or |
|
|
|
|
|
str(recset[0][5]) != str(row[21] if row[21] != '-1' else None)): |
|
|
|
|
|
|
|
|
sql = "Insert into vendors_history (vendor_id, market_id, name_vendor, rating_vendor, successfultransactions_vendor, dateinserted_vendor) Values (%s, %s, %s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
sql = "Insert into vendors_history (vendor_id, market_id, name_vendor, rating_vendor, successfultransactions_vendor, image_vendor, dateinserted_vendor) " \ |
|
|
|
|
|
"Values (%s, %s, %s, %s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
recset = [vendorId, marketId, |
|
|
recset = [vendorId, marketId, |
|
|
recset[0][2], |
|
|
recset[0][2], |
|
|
recset[0][3], |
|
|
recset[0][3], |
|
|
recset[0][4], |
|
|
recset[0][4], |
|
|
recset[0][5]] |
|
|
|
|
|
|
|
|
recset[0][5], |
|
|
|
|
|
recset[0][6]] |
|
|
|
|
|
|
|
|
cur.execute(sql, recset) |
|
|
cur.execute(sql, recset) |
|
|
|
|
|
|
|
|
sql = "Update vendors set rating_vendor = %(rating_vendor)s, successfultransactions_vendor = %(successfultransactions_vendor)s, " \ |
|
|
sql = "Update vendors set rating_vendor = %(rating_vendor)s, successfultransactions_vendor = %(successfultransactions_vendor)s, " \ |
|
|
"dateinserted_vendor = %(dateinserted_vendor)s where vendor_id = %(vendorId)s" |
|
|
|
|
|
|
|
|
"image_vendor = %(image_vendor)s, dateinserted_vendor = %(dateinserted_vendor)s where vendor_id = %(vendorId)s" |
|
|
cur.execute(sql, {'rating_vendor': row[2] if row[2] != '-1' else None, |
|
|
cur.execute(sql, {'rating_vendor': row[2] if row[2] != '-1' else None, |
|
|
'successfultransactions_vendor': row[3] if row[3] != '-1' else None, |
|
|
'successfultransactions_vendor': row[3] if row[3] != '-1' else None, |
|
|
'dateinserted_vendor': row[21], |
|
|
|
|
|
|
|
|
'image_vendor': row[21] if row[21] != '-1' else None, |
|
|
|
|
|
'dateinserted_vendor': row[23], |
|
|
'vendorId': vendorId}) |
|
|
'vendorId': vendorId}) |
|
|
|
|
|
|
|
|
return vendorId |
|
|
return vendorId |
|
@ -220,9 +229,9 @@ def create_items(cur, row, marketId, vendorId): |
|
|
|
|
|
|
|
|
sql = "Insert into items (item_id, market_id, vendor_id, name_item, description_item, cve_item, ms_item, category_item, " \ |
|
|
sql = "Insert into items (item_id, market_id, vendor_id, name_item, description_item, cve_item, ms_item, category_item, " \ |
|
|
"views_item, reviews_item, rating_item, dateadded_item, btc_item, usd_item, euro_item, quantitysold_item, " \ |
|
|
"views_item, reviews_item, rating_item, dateadded_item, btc_item, usd_item, euro_item, quantitysold_item, " \ |
|
|
"quantityleft_item, shippedfrom_item, shippedto_item, href_item, lastseen_item, dateinserted_item, " \ |
|
|
|
|
|
|
|
|
"quantityleft_item, shippedfrom_item, shippedto_item, lastseen_item, image_item, href_item, dateinserted_item, " \ |
|
|
"classification_item) Values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " \ |
|
|
"classification_item) Values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " \ |
|
|
"%s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
"%s, %s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
recset = [itemId, marketId, vendorId, |
|
|
recset = [itemId, marketId, vendorId, |
|
|
row[4], |
|
|
row[4], |
|
@ -241,10 +250,11 @@ def create_items(cur, row, marketId, vendorId): |
|
|
row[17] if row[17] != '-1' else None, |
|
|
row[17] if row[17] != '-1' else None, |
|
|
row[18] if row[18] != '-1' else None, |
|
|
row[18] if row[18] != '-1' else None, |
|
|
row[19] if row[19] != '-1' else None, |
|
|
row[19] if row[19] != '-1' else None, |
|
|
|
|
|
row[23], |
|
|
row[20] if row[20] != '-1' else None, |
|
|
row[20] if row[20] != '-1' else None, |
|
|
row[21], |
|
|
|
|
|
row[21], |
|
|
|
|
|
row[22]] |
|
|
|
|
|
|
|
|
row[22] if row[22] != '-1' else None, |
|
|
|
|
|
row[23], |
|
|
|
|
|
row[24]] |
|
|
|
|
|
|
|
|
cur.execute(sql, recset) |
|
|
cur.execute(sql, recset) |
|
|
|
|
|
|
|
@ -262,13 +272,14 @@ def create_items(cur, row, marketId, vendorId): |
|
|
str(recset[0][10]) != str(row[11] if row[11] != '-1' else None) or str(recset[0][11]) != str(row[12] if row[12] != '-1' else None) or |
|
|
str(recset[0][10]) != str(row[11] if row[11] != '-1' else None) or str(recset[0][11]) != str(row[12] if row[12] != '-1' else None) or |
|
|
str(recset[0][12]) != str(row[13] if row[13] != '-1' else None) or str(recset[0][13]) != str(row[14] if row[14] != '-1' else None) or |
|
|
str(recset[0][12]) != str(row[13] if row[13] != '-1' else None) or str(recset[0][13]) != str(row[14] if row[14] != '-1' else None) or |
|
|
str(recset[0][14]) != str(row[15] if row[15] != '-1' else None) or str(recset[0][15]) != str(row[16] if row[16] != '-1' else None) or |
|
|
str(recset[0][14]) != str(row[15] if row[15] != '-1' else None) or str(recset[0][15]) != str(row[16] if row[16] != '-1' else None) or |
|
|
str(recset[0][16]) != str(row[17] if row[17] != '-1' else None) or str(recset[0][17]) != str(row[18] if row[18] != '-1' else None)): |
|
|
|
|
|
|
|
|
str(recset[0][16]) != str(row[17] if row[17] != '-1' else None) or str(recset[0][17]) != str(row[18] if row[18] != '-1' else None) or |
|
|
|
|
|
str(recset[0][18]) != str(row[19] if row[19] != '-1' else None) or str(recset[0][20]) != str(row[20] if row[20] != '-1' else None)): |
|
|
|
|
|
|
|
|
sql = "Insert into items_history (item_id, market_id, vendor_id, name_item, description_item, cve_item, ms_item, category_item, " \ |
|
|
sql = "Insert into items_history (item_id, market_id, vendor_id, name_item, description_item, cve_item, ms_item, category_item, " \ |
|
|
"views_item, reviews_item, rating_item, dateadded_item, btc_item, usd_item, euro_item, quantitysold_item, " \ |
|
|
"views_item, reviews_item, rating_item, dateadded_item, btc_item, usd_item, euro_item, quantitysold_item, " \ |
|
|
"quantityleft_item, shippedfrom_item, shippedto_item, href_item, lastseen_item, dateinserted_item, " \ |
|
|
|
|
|
|
|
|
"quantityleft_item, shippedfrom_item, shippedto_item, lastseen_item, image_item, href_item, dateinserted_item, " \ |
|
|
"classification_item) Values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " \ |
|
|
"classification_item) Values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " \ |
|
|
"%s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
"%s, %s, %s, %s, %s)" |
|
|
|
|
|
|
|
|
recset = [itemId, marketId, vendorId, |
|
|
recset = [itemId, marketId, vendorId, |
|
|
recset[0][3], |
|
|
recset[0][3], |
|
@ -290,7 +301,8 @@ def create_items(cur, row, marketId, vendorId): |
|
|
recset[0][19], |
|
|
recset[0][19], |
|
|
recset[0][20], |
|
|
recset[0][20], |
|
|
recset[0][21], |
|
|
recset[0][21], |
|
|
recset[0][22]] |
|
|
|
|
|
|
|
|
recset[0][22], |
|
|
|
|
|
recset[0][23]] |
|
|
|
|
|
|
|
|
cur.execute(sql, recset) |
|
|
cur.execute(sql, recset) |
|
|
|
|
|
|
|
@ -299,7 +311,7 @@ def create_items(cur, row, marketId, vendorId): |
|
|
"rating_item = %(rating_item)s, dateadded_item = %(dateadded_item)s, btc_item = %(btc_item)s, " \ |
|
|
"rating_item = %(rating_item)s, dateadded_item = %(dateadded_item)s, btc_item = %(btc_item)s, " \ |
|
|
"usd_item = %(usd_item)s, euro_item = %(euro_item)s, quantitysold_item = %(quantitysold_item)s, " \ |
|
|
"usd_item = %(usd_item)s, euro_item = %(euro_item)s, quantitysold_item = %(quantitysold_item)s, " \ |
|
|
"quantityleft_item = %(quantityleft_item)s, shippedfrom_item = %(shippedfrom_item)s, shippedto_item = %(shippedto_item)s, " \ |
|
|
"quantityleft_item = %(quantityleft_item)s, shippedfrom_item = %(shippedfrom_item)s, shippedto_item = %(shippedto_item)s, " \ |
|
|
"lastseen_item = %(lastseen_item)s, dateinserted_item = %(dateinserted_item)s where item_id = %(itemId)s" |
|
|
|
|
|
|
|
|
"lastseen_item = %(lastseen_item)s, image_item = %(image_item)s, dateinserted_item = %(dateinserted_item)s where item_id = %(itemId)s" |
|
|
|
|
|
|
|
|
cur.execute(sql, {'description_item': row[5] if row[5] != '-1' else None, |
|
|
cur.execute(sql, {'description_item': row[5] if row[5] != '-1' else None, |
|
|
'cve_item': row[6] if row[6] != '-1' else None, |
|
|
'cve_item': row[6] if row[6] != '-1' else None, |
|
@ -316,8 +328,9 @@ def create_items(cur, row, marketId, vendorId): |
|
|
'quantityleft_item': row[17] if row[17] != '-1' else None, |
|
|
'quantityleft_item': row[17] if row[17] != '-1' else None, |
|
|
'shippedfrom_item': row[18] if row[18] != '-1' else None, |
|
|
'shippedfrom_item': row[18] if row[18] != '-1' else None, |
|
|
'shippedto_item': row[19] if row[19] != '-1' else None, |
|
|
'shippedto_item': row[19] if row[19] != '-1' else None, |
|
|
'dateinserted_item': row[21], |
|
|
|
|
|
'lastseen_item': row[21], |
|
|
|
|
|
|
|
|
'dateinserted_item': row[23], |
|
|
|
|
|
'lastseen_item': row[23], |
|
|
|
|
|
'image_item': row[20], |
|
|
'itemId': itemId}) |
|
|
'itemId': itemId}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -325,7 +338,7 @@ def create_items(cur, row, marketId, vendorId): |
|
|
|
|
|
|
|
|
sql = "Update items set lastseen_item = %(lastseen_item)s where item_id = %(itemId)s" |
|
|
sql = "Update items set lastseen_item = %(lastseen_item)s where item_id = %(itemId)s" |
|
|
|
|
|
|
|
|
cur.execute(sql, {'lastseen_item': row[21], |
|
|
|
|
|
|
|
|
cur.execute(sql, {'lastseen_item': row[23], |
|
|
'itemId': itemId}) |
|
|
'itemId': itemId}) |
|
|
|
|
|
|
|
|
return itemId |
|
|
return itemId |
|
@ -344,8 +357,8 @@ def create_database(cur, con): |
|
|
|
|
|
|
|
|
sql = "create table vendors(vendor_id integer not null, market_id integer not null, name_vendor character " \ |
|
|
sql = "create table vendors(vendor_id integer not null, market_id integer not null, name_vendor character " \ |
|
|
"varying(255) not null, rating_vendor character varying(255), successfultransactions_vendor integer " \ |
|
|
"varying(255) not null, rating_vendor character varying(255), successfultransactions_vendor integer " \ |
|
|
"null, dateinserted_vendor timestamp(6) with time zone not null, constraint vendors_pk primary key (" \ |
|
|
|
|
|
"vendor_id), constraint vendors_market_id_fkey foreign key (market_id) references marketplaces (" \ |
|
|
|
|
|
|
|
|
"null, image_vendor character varying(1000000) null, dateinserted_vendor timestamp(6) with time zone not null, " \ |
|
|
|
|
|
"constraint vendors_pk primary key (vendor_id), constraint vendors_market_id_fkey foreign key (market_id) references marketplaces (" \ |
|
|
"market_id))" |
|
|
"market_id))" |
|
|
cur.execute(sql) |
|
|
cur.execute(sql) |
|
|
|
|
|
|
|
@ -354,8 +367,8 @@ def create_database(cur, con): |
|
|
|
|
|
|
|
|
sql = "create table vendors_history(vendor_id integer not null, market_id integer not null, name_vendor " \ |
|
|
sql = "create table vendors_history(vendor_id integer not null, market_id integer not null, name_vendor " \ |
|
|
"character varying(255) not null, rating_vendor character varying(255), successfultransactions_vendor " \ |
|
|
"character varying(255) not null, rating_vendor character varying(255), successfultransactions_vendor " \ |
|
|
"integer null, dateinserted_vendor timestamp(6) with time zone not null, constraint vendors_history_pk " \ |
|
|
|
|
|
"primary key (vendor_id, dateinserted_vendor), constraint vendors_history_vendor_id_fkey foreign key (" \ |
|
|
|
|
|
|
|
|
"integer null, image_vendor character varying(1000000) null, dateinserted_vendor timestamp(6) with time zone not null, " \ |
|
|
|
|
|
"constraint vendors_history_pk primary key (vendor_id, dateinserted_vendor), constraint vendors_history_vendor_id_fkey foreign key (" \ |
|
|
"vendor_id) references vendors (vendor_id), constraint vendors_history_market_id_fkey foreign key (" \ |
|
|
"vendor_id) references vendors (vendor_id), constraint vendors_history_market_id_fkey foreign key (" \ |
|
|
"market_id) references marketplaces (market_id))" |
|
|
"market_id) references marketplaces (market_id))" |
|
|
cur.execute(sql) |
|
|
cur.execute(sql) |
|
@ -367,9 +380,9 @@ def create_database(cur, con): |
|
|
"character varying(25) null, btc_item character varying(255) null, usd_item character varying(255) " \ |
|
|
"character varying(25) null, btc_item character varying(255) null, usd_item character varying(255) " \ |
|
|
"null, euro_item character varying(255) null, quantitysold_item integer null, quantityleft_item " \ |
|
|
"null, euro_item character varying(255) null, quantitysold_item integer null, quantityleft_item " \ |
|
|
"character varying(255) null, shippedfrom_item character varying(255) null, shippedto_item character " \ |
|
|
"character varying(255) null, shippedfrom_item character varying(255) null, shippedto_item character " \ |
|
|
"varying(255) null, href_item character varying(255) not null, lastseen_item timestamp(6) with time zone " \ |
|
|
|
|
|
"not null, dateinserted_item timestamp(6) with time zone not null, classification_item double " \ |
|
|
|
|
|
"precision not null, constraint items_pk primary key (item_id), constraint " \ |
|
|
|
|
|
|
|
|
"varying(255) null, lastseen_item timestamp(6) with time zone not null, image_item character varying(1000000) null, " \ |
|
|
|
|
|
"href_item character varying(255) not null, dateinserted_item timestamp(6) with time zone not null, " \ |
|
|
|
|
|
"classification_item double precision not null, constraint items_pk primary key (item_id), constraint " \ |
|
|
"items_market_id_fkey foreign key (market_id) references marketplaces (market_id),constraint " \ |
|
|
"items_market_id_fkey foreign key (market_id) references marketplaces (market_id),constraint " \ |
|
|
"items_vendor_id_fkey foreign key (vendor_id) references vendors (vendor_id))" |
|
|
"items_vendor_id_fkey foreign key (vendor_id) references vendors (vendor_id))" |
|
|
cur.execute(sql) |
|
|
cur.execute(sql) |
|
@ -384,9 +397,9 @@ def create_database(cur, con): |
|
|
"character varying(25) null, btc_item character varying(255) null, usd_item character varying(255) " \ |
|
|
"character varying(25) null, btc_item character varying(255) null, usd_item character varying(255) " \ |
|
|
"null, euro_item character varying(255) null, quantitysold_item integer null, quantityleft_item " \ |
|
|
"null, euro_item character varying(255) null, quantitysold_item integer null, quantityleft_item " \ |
|
|
"character varying(255) null, shippedfrom_item character varying(255) null, shippedto_item character " \ |
|
|
"character varying(255) null, shippedfrom_item character varying(255) null, shippedto_item character " \ |
|
|
"varying(255) null, href_item character varying(255) not null, lastseen_item timestamp(6) with time zone " \ |
|
|
|
|
|
"not null, dateinserted_item timestamp(6) with time zone not null, classification_item double " \ |
|
|
|
|
|
"precision not null, constraint items_history_pk primary key (item_id, dateinserted_item), " \ |
|
|
|
|
|
|
|
|
"varying(255) null, lastseen_item timestamp(6) with time zone not null, image_item character varying(1000000) null, " \ |
|
|
|
|
|
"href_item character varying(255) not null, dateinserted_item timestamp(6) with time zone not null, " \ |
|
|
|
|
|
"classification_item double precision not null, constraint items_history_pk primary key (item_id, dateinserted_item), " \ |
|
|
"constraint items_history_market_id_fkey foreign key (market_id) references marketplaces (market_id), " \ |
|
|
"constraint items_history_market_id_fkey foreign key (market_id) references marketplaces (market_id), " \ |
|
|
"constraint items_history_vendor_id_fkey foreign key (vendor_id) references vendors (vendor_id), " \ |
|
|
"constraint items_history_vendor_id_fkey foreign key (vendor_id) references vendors (vendor_id), " \ |
|
|
"constraint items_history_item_id_fkey foreign key (item_id) references items (item_id))" |
|
|
"constraint items_history_item_id_fkey foreign key (item_id) references items (item_id))" |
|
|