andre.zf Posted October 3, 2012 Report Share Posted October 3, 2012 I have utorrent version 3.2, windows 7 and python compiler version 3.3.I've read the entire section of the website http://www.utorrent.com/intl/en/community/developers/webapi # devs3.My goal: it's get data of torrent link that is downloading (speed, status, size, etc).I've tried to get the data (hash, status, progress, size, dl_speed, ul_speed, ratio, etc.) of torrent from utorrent.I think that I have suitable tools such as a module in python called "requests" (newest version) to connect to http://localhost:32768/gui/token.html and I have a webUI too installed.The python seems to do its job, but it doesn't get the data from utorrent that I want. I've read several other articles and I did not succeed to how to do that.I can't read any information from utorrent and I doesn't get to list the torrents that are downloads.I am beginner and very curious, I want to learn how to make a python program to get the data about torrent links that are downloaded on the utorrent. Link to comment Share on other sites More sharing options...
andre.zf Posted December 2, 2012 Author Report Share Posted December 2, 2012 I made the code below to gather torrent detailsimport requestsimport json# Pega a tokenID para autenticar o acesso aos dados estatísticos do utorrenttokenID = requests.get('http://localhost:32768/gui/token.html', auth=('nano','xxx'))#Parser para extrair somente o tokentoken = tokenID.text.split('>')[2].split('<')[0]#Autenticação com user + senha + tokenreq = requests.get('http://localhost:32768/gui/', auth=('nano', 'xxx'), params={'list':'1','token':token})When I've typed req.text on python console I get the message: "invalid request'what is it going on? Link to comment Share on other sites More sharing options...
neonpolaris Posted December 25, 2012 Report Share Posted December 25, 2012 I have something similar that I'm working on. My tokens always end with '=' which requests changes to an '%3D' in the url. Not sure how to prevent that yet. I'll let you know if I figure it out. Have you solved it yet? Link to comment Share on other sites More sharing options...
ciaobaby Posted December 25, 2012 Report Share Posted December 25, 2012 My tokens always end with '=' which requests changes to an '%3D'%3D is the hexadecimal ASCII code for the = sign and is converted because the = sign is ONLY allowed in URLs to delimit a key/value pair in URL parameters.eg:viewtopic.php?pid=701962#p701962The conversion process is called URL Encoding, where all 'illegal' characters are converted to their hex equivalent, Link to comment Share on other sites More sharing options...
elian83 Posted December 25, 2012 Report Share Posted December 25, 2012 1) uTorrent server can handle both '=' and '3D%'2) You are missing out the GUID cookie in your request. That's why you receive the 'invalid request' message.Example:import requestsreq = requests.get('http://localhost:8080/gui/token.html', auth=('admin',''))token = req.text.split('>')[2].split('<')[0]guid = req.cookies['GUID']cookies = dict(GUID = guid);req = requests.get('http://localhost:8080/gui/', auth=('admin', ''), params={'list':'1','token':token}, cookies=cookies)print req.text Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.