-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a16b887
commit 8530eba
Showing
13 changed files
with
374 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .generic_html import ScraperSupport | ||
from .product_list import product_categories | ||
from .database_util import DatabaseUtil | ||
from .request_handler import RequestHandler | ||
|
||
__all__ = [ | ||
"ScraperSupport", | ||
"product_categories", | ||
"DatabaseUtil", | ||
"RequestHandler" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import logging | ||
import os | ||
from datetime import datetime | ||
import lxml.html as html | ||
import pandas as pd | ||
import warnings | ||
warnings.filterwarnings("ignore") | ||
|
||
class htmlLib: | ||
def __init__(self, timeout=10): | ||
self.stamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") | ||
self.storagePath = os.path.join( | ||
os.path.dirname(os.path.abspath(__file__)), "../" | ||
) | ||
|
||
def get_xpath_link(self, doc, xpath, website): | ||
try: | ||
name = doc.xpath("".join(xpath)) | ||
print(name) | ||
for i in range(len(name)): | ||
if name[i].startswith("/"): | ||
name[i] = website + name[i] | ||
else: | ||
name[i] = name[i] | ||
return name | ||
|
||
except Exception as e: | ||
logging.info("Error in getting {}: {}".format(name, e)) | ||
pass | ||
return None | ||
pass | ||
|
||
def get_xpath_data(self, doc, xpath): | ||
try: | ||
name = doc.xpath(xpath) | ||
return name | ||
|
||
except Exception as e: | ||
print("Error in getting {}: {}".format(name, e)) | ||
pass | ||
return None | ||
|
||
def data_storage(self, df_list, unique_id, name): | ||
df_combined = pd.concat(df_list, ignore_index=True) | ||
df_combined.drop_duplicates(subset=unique_id, inplace=True) | ||
df_combined.to_csv( | ||
self.storagePath + "raw/" + "{}_{}.csv".format(name, self.stamp), | ||
index=False, | ||
) | ||
|
||
def cleanData(self, array): | ||
array = [x.strip() for x in array] | ||
array = list(filter(None, array)) | ||
array = [x.encode("ascii", "ignore").decode() for x in array] | ||
array = [x.replace("\n", "") for x in array] | ||
return array | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
product_categories = [ | ||
'mobiles', | ||
'laptops', | ||
'televisions', | ||
'cameras', | ||
'headphones', | ||
'speakers', | ||
'watches', | ||
'air-conditioners', | ||
'refrigerators', | ||
'washing-machines', | ||
'books', | ||
'shoes', | ||
'clothing', | ||
'bags', | ||
'jewellery', | ||
'home-decor', | ||
'home-furnishing', | ||
'cricket-equipments', | ||
'football-equipments', | ||
'badminton-equipments', | ||
'table-tennis-equipments', | ||
'gym-equipments', | ||
'kitchen-appliances', | ||
'home-appliances', | ||
'home-entertainment', | ||
'home-improvement-tools', | ||
] |
Oops, something went wrong.