Python Forum
Send a requests to a magnet links shortener which doesn't have APIs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send a requests to a magnet links shortener which doesn't have APIs
#1
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
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
200
then 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?
Reply


Messages In This Thread
Send a requests to a magnet links shortener which doesn't have APIs - by Ascalon - Feb-18-2022, 12:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  POST requests - different requests return the same response Default_001 3 2,123 Mar-10-2022, 11:26 PM
Last Post: Default_001
  webscrapping links and then enter those links to scrape data kirito85 2 3,437 Jun-13-2019, 02:23 AM
Last Post: kirito85

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020