Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Get A Web Page Via A Post Request In Python

This is an example of how to use the Python [TODO: Code shorthand span ] module to send a POST request to a web server that includes headers and a json payload. (The specific example is for a meilisearch server in this case.)

NOTE : I'm pretty sure you need to install [TODO: Code shorthand span ] with [TODO: Code shorthand span ] or ` pip3 ` . For example :

bash
pip install requests

Note : the results have been locked in so the bearer token can be removed. The code has been set to : eval never to prevent accidentally running it.

#+NAME : listing - 1 #+begin _ src python : post results _ padder(data=*this*) : results output : wrap example : eval never

import requests

url = 'http : //127.0.0.1 : 7700/indexes/grimoire/search'

headers = { 'Authorization' : 'Bearer aaaaabbbbbccccccddddddd', 'Content - Type' : 'application/json' }

data = { 'q' : 'example' }

response = requests.post(url, headers=headers, json=data)

print(f'Status : {response.status _ code}') print(f'Returned : {response.json()}')

#+end _ src

results start

TODO : Link up other version of getting pages via GET