How can I save python HTTP requests from python-recets so that I can execute it later?

I want to save an HTTP request made through a python request library, so I can execute them later with minimal effort.

Note that it would be great if I could save them in a format that would allow me to restore them, even if the python requests are modified.

+4
source share
1 answer

If you intend to save certain sites and explicit requests, simply write the r.url value to a text file. Here is the basic idea:

import requests url = "http://example.com/" r = requests.get(url) afile = open("/path/to/filename.txt", "a") afile.write(r.url) afile.write("\n") afile.close() 

Note. If you do this with a POST request and include the authentication data, then secret data (auth keys, passwords, etc.) can be stored in the file.

-2
source

Source: https://habr.com/ru/post/1499103/


All Articles