Skip to content
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

Parsing codexes #26

Merged
merged 17 commits into from
Nov 23, 2018
Merged

Parsing codexes #26

merged 17 commits into from
Nov 23, 2018

Conversation

navolotsky
Copy link
Member

@navolotsky navolotsky commented Nov 14, 2018

Pull Request

Описание

Парсинг кодексов (ГК, НК, КоАП, УК), ниже частей пока не делит. Так же сохраняет редакции в файл в виде json-строк. Использование обычного json невозможно из-за объема данных.

Закрытые issues

closes #21
closes #22
closes #23

Дополнительная информация

Под кодексы нужно обновить модели в базе, так как добавились новые поля. Описаны будут на скриншотах ниже.

Также из-за объема кодексов они хранятся не в json-файле, а в файле, где каждая строка — корректный json, если эти строки объединить, то получился бы исходный json-файл.

Ссылка на ГК, НК, КоАП, УК https://yadi.sk/d/tLWbHXdSAIzxMw

Скриншот 1. Как это выглядит в файле
image

Скриншот 2. Кодекс, редакция
image

Скриншот 3. Подробнее про cons_selected_info
image

Скриншот 4. Некоторая дополнительная информация
image

@Vasar007 Vasar007 added type/feature New feature as a list of functional requirements of the client's point of view priority/top Top issue priority labels Nov 19, 2018
@Vasar007 Vasar007 added this to In progress in Веб-краулер via automation Nov 19, 2018
@Vasar007 Vasar007 added this to the просто камень milestone Nov 19, 2018
@navolotsky navolotsky moved this from In progress to Need to review in Веб-краулер Nov 23, 2018
Rexarrior
Rexarrior previously approved these changes Nov 23, 2018
encoding='utf-8') as file:
file.write(doc_id + '\n')
# print('ok')
# pathToFile = f'{cls.CODE_PART_KEY}.json'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опять много комментариев с кодом)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Удалил неиспользуемое. Остальные нужны, в тех местах непосредственно будет продолжена разработка.

codes = {'КОАПРФ', 'НКРФ', 'ГКРФ', 'УКРФ'}
get_content(codes)
print(f"\nCodes processing spent {time.time()-start_time} seconds.\n")
input("press any key...")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так норм, но если дальше потребуется расширение, нужно применять паттерны. Куча if-выражений всегда является признаком "кода с запахом", думаю, тут КА может хорошо зайти. Ну, а пока так оставим.

@@ -135,7 +135,7 @@ def get_decision_headers(pagesNumber=None, sourcePrefix='КСРФ'):
page = html.document_fromstring(get_page_html_by_num(
driver, template, i))
if True: # debug print:
print(f"Pages downloaded: {i-1}/{pagesNumber}")
print(f"Pages downloaded: {i-1}/{pagesNumber}", end='\r')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему именно end='\r'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возврат каретки. Чтобы при обновлении строки менялся номер, а не выводилась новая строка.

Copy link
Member

@Vasar007 Vasar007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ок, понял

Copy link
Member

@Vasar007 Vasar007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда удали неиспользуемый код и сливай.

@navolotsky navolotsky merged commit 2e04323 into IntenseWeek Nov 23, 2018
Веб-краулер automation moved this from Need to review to Done Nov 23, 2018
@navolotsky navolotsky deleted the parsingCodexes branch November 23, 2018 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/top Top issue priority type/feature New feature as a list of functional requirements of the client's point of view
Projects
Development

Successfully merging this pull request may close these issues.

Парсинг НК РФ Парсинг ГК РФ Парсинг КоАП РФ
3 participants