Skip to content

Instantly share code, notes, and snippets.

@bhavyagaur99
Last active July 4, 2022 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhavyagaur99/e664b6bd7d08d17995fac069e6d32acf to your computer and use it in GitHub Desktop.
Save bhavyagaur99/e664b6bd7d08d17995fac069e6d32acf to your computer and use it in GitHub Desktop.
# make sure you have python3 and pip3 installed on your computer
# make sure to have requests library installed (pip3 install requests)
import requests
filename = 'your document file here.docx' # can be any supported file like pdf, csv etc
url = 'https://text-analysis12.p.rapidapi.com/text-mining/api/v1.1'
headers = {
'x-rapidapi-key': '<***important*** replace your key here>',
'x-rapidapi-host': 'text-analysis12.p.rapidapi.com'
}
files = {
'input_file': open(filename, 'rb')
}
response = requests.post(url=url, headers=headers, files=files)
result = response.json()
if result['ok']:
text = result['text']
print(f'text from {filename} is:')
print(text)
# do_something_with_text(text)
else:
print(f'error: {result["msg"]}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment