In addition to API bindings, krdict.py provides a scraper module that offers functions that fetch information from the dictionary website and extend the results of word search queries, advanced search queries, and view queries.
These extensions can be applied directly to results during query calls with the use_scraper
option, but are also accessible via the krdict.scraper
module.
Warning
Because this module utilizes scraping, the reliability of results cannot be guaranteed. At any time, functions may break entirely and remain broken until a patch is released. If there are errors or improper results, please submit an issue.
extend_advanced_search¶
Extends advanced word search results with pronunciation URLs.
def extend_advanced_search(
response: WordSearchResponse,
raise_errors: bool
) -> WordSearchResponse: ...
Parameters:
response
: The word search results to extend.raise_errors
: Whether errors that occur during scraping should be raised or ignored.
Returns:
Returns an extended WordSearchResponse
object.
extend_search¶
Extends word search results with pronunciation URLs.
def extend_search(
response: WordSearchResponse,
raise_errors: bool
) -> WordSearchResponse: ...
Parameters:
response
: The word search results to extend.raise_errors
: Whether errors that occur during scraping should be raised or ignored.
Returns:
Returns an extended WordSearchResponse
object.
extend_view¶
Extends view query results with pronunciation URLs, multimedia information, and extended hanja information.
def extend_view(
response: ViewResponse,
fetch_page_data: bool,
fetch_multimedia: bool,
raise_errors: bool
) -> ViewResponse: ...
Parameters:
response
: The word search results to extend.fetch_page_data
: Whether page data (URLs and hanja information) should be scraped.fetch_multimedia
: Whether multimedia URLs should be scraped.raise_errors
: Whether errors that occur during scraping should be raised or ignored.
Returns:
Returns an extended ViewResponse
object.
fetch_today_word¶
Fetches the Korean word of the day by scraping the dictionary website.
def fetch_today_word(*,
guarantee_keys: bool = False,
translation_language: ScraperTranslationLanguage = None
) -> WordOfTheDayResponse: ...
Parameters:
guarantee_keys
: Sets whether keys that are missing from the response should be inserted with default values. A value ofTrue
guarantees that every key that is not required is included, including keys set by the scraper. Default values:- The empty string
""
for string values. - Zero
0
for integer values. - An empty list
[]
for list values. None
for dictionary values. This only applies to thetranslation
field.
- The empty string
translation_language
(ScraperTranslationLanguage
): A language to include a translation for.
Returns:
Returns a WordOfTheDayResponse
object.
fetch_meaning_category_words¶
Fetches words that belong to the provided meaning category.
def fetch_meaning_category_words(*,
guarantee_keys: bool = False,
category: MeaningCategory | int = 0,
page: int = 1,
per_page: int = 10,
sort: SortMethod = 'alphabetical',
translation_language: ScraperTranslationLanguage = None
) -> ScrapedWordSearchResponse: ...
Warning
The '전체'
or 0
MeaningCategory option is not supported and will return zero results.
Parameters:
guarantee_keys
: Sets whether keys that are missing from the response should be inserted with default values. A value ofTrue
guarantees that every key that is not required is included, including keys set by the scraper. Default values:- The empty string
""
for string values. - Zero
0
for integer values. - An empty list
[]
for list values. None
for dictionary values. This only applies to thetranslation
field.
- The empty string
category
: The meaning category to fetch.page
: The page at which the search should start[1, 1000]
.per_page
: The maximum number of search results to return[10, 100]
.sort
(SortMethod
): The sort method that should be used.translation_language
(ScraperTranslationLanguage
): A language to include translations for.
Returns:
Returns a ScrapedWordSearchResponse
object.
fetch_subject_category_words¶
Fetches words that belong to one of the provided subject categories.
def fetch_subject_category_words(*,
guarantee_keys: bool = False,
category: SubjectCategory | int | List[SubjectCategory | int] = 0,
page: int = 1,
per_page: int = 0,
sort: SortMethod = 'alphabetical',
translation_language: ScraperTranslationLanguage = None
) -> ScrapedWordSearchResponse: ...
Parameters:
guarantee_keys
: Sets whether keys that are missing from the response should be inserted with default values. A value ofTrue
guarantees that every key that is not required is included, including keys set by the scraper. Default values:- The empty string
""
for string values. - Zero
0
for integer values. - An empty list
[]
for list values. None
for dictionary values. This only applies to thetranslation
field.
- The empty string
category
: The subject category to fetch.page
: The page at which the search should start[1, 1000]
.per_page
: The maximum number of search results to return[10, 100]
.sort
(SortMethod
): The sort method that should be used.translation_language
(ScraperTranslationLanguage
): A language to include translations for.
Returns:
Returns a ScrapedWordSearchResponse
object.