Skip to main content

Python wrapper to help parse the Merriam-Webster API response

Project description

Package Name: MW_API_Parser Author: Jerry White Package URL: https://github.com/whitej27030/mw_api_parser.git

Built using: Merriam-Webster API - https://DictionaryAPI.com

This repository contains scripts which allow you to access definitions, audio pronunciation and more from Merriam-Webster's online dictionary.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

This package MUST be installed on Python versions 3.11 or later

You will also need to visit:"https://www.dictionaryapi.com/". Click on "Dev Center" and sign-up. Make sure you make note of your API keys as you will need them later.

Next, you will need to create a .env file. This file should contain the reference work you will contact with this script and your Merriam-Webster API key. There is a "Sample_Env.txt" file in the project directory that you can use as a template. You can rename this file to ".env" (without the quotes), and place your Merriam-Webster API Key where noted. The current version will only work properly with the "collegiate" reference API, so this line should not be modified.

If you would rather keep the .env file in another location, you can set an environment variable named "MW_API_PARSER_CONFIG" (again, without the quotes), using the commands for your operating system below:

First, open a command line session on your given OS, then:

  • On Linux / Mac OS: export MW_API_PARSER_CONFIG=/Path_To_Folder_Containing_Env_File/ Make sure you include the '/' at the end of the path!
  • On Windows: setx MW_API_PARSER_CONFIG "c:/<Path_To_Folder_Containing_Env_File/"

Make sure you put the '/' at the end of the folder path!

Also note that the Windows setx command only adds the environment variable to the current session. To set this variable globally, the command will need to be ran with Administrator rights.

Installing

Clone or download this repository to your local machine. You can also install from PyPI with the following command:

'pip install mw_api_parser'

Scripts

MW_Response

This first script will retrieve the definition for the word passed into the function. In this case, the word passed in is "jaded".

from mw_api_parser import MW_Response

response = MW_Response('jaded')

Build_Audio_Links

This script will create a list of audio links for the word passed in.

from mw_api_parser import Build_Audio_Links

links = Build_Audio_Links(test1)

print(type(links))

for x in range(0, len(links)):
    print(links[x])

Get_Def_HTML

This script will return a list of HTML code containing the definition for the word passed in.

from mw_api_parser import Get_Def_HTML

html_response = Get_Def_HTML(test1)

print(type(html_response))

for x in range(0, len(html_response + '\n'))
    print(html_response[x])

Get_Def_Original

This script will return a list containing the original definition for the word passed in.

from mw_api_parser import Get_Def_Original

orig_response = Get_Def_Original(test1)

print(type(orig_response))

for x in range(0, len(orig_response)):
    print(orig_response[x] + '\n')

Get_Def_Plain_Text

This script will return a list containing the plain text definition for the word passed in.

from mw_api_parser import Get_Def_Plain_Text

plain_text = Get_Def_Plain_Text(test2)

print(type(plain_text))

for x in range(0, len(plain_text)):
    print(plain_text[x])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mw_api_parser-1.0.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mw_api_parser-1.0.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file mw_api_parser-1.0.1.tar.gz.

File metadata

  • Download URL: mw_api_parser-1.0.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for mw_api_parser-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ca1ae4465c89b507ca0a313d5d7b6e8034ac04549fa3bf8ef27ffd5fc9a8043c
MD5 1b5eb983fbfaabed5b0d086c831debfb
BLAKE2b-256 aeeeacc5569abe6646fad13b68ad81b4b1f22acc676d84106758fe7ff0b4e0c2

See more details on using hashes here.

File details

Details for the file mw_api_parser-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mw_api_parser-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for mw_api_parser-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 20adff247b0f78b7214c59fd12fed6bdf1d88b07c275b8600ba9d5a1c7f96f5e
MD5 ac19a07e932e134d40ca872dbdcc9091
BLAKE2b-256 703d41b7e9624a0bd14859f76a1883e559d02997e298b85a0cb30ed3d6c794aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page