Feb-18-2022, 12:23 AM
Hi, there is this website where you enter a torrent magnet link and you get a short url redirecting to the magnet link.
I'd like to do the procedure with python but the website doesn't have APIs, so after a quick research it seems that I have to use requests.post, but I don't understand how to find the data and headers to put in the requests.
This is my first try based on a snippet code that I found on internet
I'd like to do the procedure with python but the website doesn't have APIs, so after a quick research it seems that I have to use requests.post, but I don't understand how to find the data and headers to put in the requests.
This is my first try based on a snippet code that I found on internet
import requests, json url = "https://tormag.ezpz.work/" data = {'magnet_link': 'magnet:?xt=urn:btih:44EA47CF8DF204C8E5DF79A255809D47AC94C21B'} headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} r = requests.post(url, data=json.dumps(data), headers=headers) r.status_code 200then I run the command r.json() to look at the available headers but it raised this error
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 897, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)Any help?