-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dataset Collector #1, Kazyulina Marina - 19FPL1 #42
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to this moment, it is the first more or less recursive parser. however, there is a spaghetti code and broken single responsibility principle
config/constants.py
Outdated
Useful constant variables | ||
""" | ||
|
||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all constants should be left in constants.py in the root of the project
@@ -7,3 +7,5 @@ | |||
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) | |||
ASSETS_PATH = os.path.join(PROJECT_ROOT, 'tmp', 'articles') | |||
CRAWLER_CONFIG_PATH = os.path.join(PROJECT_ROOT, 'crawler_config.json') | |||
LINKS_STORAGE = os.path.join(PROJECT_ROOT, 'links') | |||
URL_START = 'https://burunen.ru' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is seed url or any other configuration of the crawler, then use configuration file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, it is the beginning of every url in my sourse
you see, as in many webpages, the href tags in my source are filled with the continuation of the url, emitting the 'https://burunen.ru', so each and every time i try to request the link i found automatically i have to concatenate it with this beginning first.
i thought about making an additional attribute to the Crawler class (something like self.url_start = "), but then i decided that if it is constant, it should be placed among other constants... am i wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very well! need to polish
|
||
def _scan_dataset(self): | ||
""" | ||
Register each dataset entry | ||
""" | ||
pass | ||
path = Path(ASSETS_PATH) | ||
for file in path.iterdir(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you find a way to directly get files by the given name template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve
pipeline.py
Outdated
raise NotADirectoryError | ||
if not list(path.iterdir()): | ||
raise EmptyDirectoryError | ||
files = [str(file.relative_to(path)) for file in path.iterdir()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more
pipeline.py
Outdated
|
||
def get_articles(self): | ||
""" | ||
Returns storage params | ||
""" | ||
pass | ||
self._scan_dataset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it cannot be in the plain getter - read the requirements
No description provided.