Using request library for Pirates
Few years ago using urllib2 was a simplest way for sending and receiving HTTP Request. But now I'm using Request library . This is more simple and powerful. Unfortunately Request is not include in default install and Pip should be used .
Procedure is really simple and near to standard :
Few lines of code.
Request has a good documentation at : http://docs.python-requests.org/en/master/ It will be nice to check it if you have any misunderstanding. Lets back to pirates game. One of the first request is three requests for selecting correct segment for playing. List is a powerful and very important feature of the python language. If you have worked with C or C++ you should know how much time requires understanding of pointers and correct using. Python is doing this in light and easy to understand way. Good tutorial is here : https://www.tutorialspoint.com/python/python_lists.htm
I've created a function hot to send requests and select proper segment for future requests:
How its works ?
Lines 3-6 are our python list of the url.
Line 8 is adding some header to the request such as client version , sever method etc.
Lines 9-12 are python loop: request is send to each url . Correct answer is started from digits (timestamp), incorrect is started from symbol "!". Correct URL is returned.
All script code are placed at : https://pastebin.com/ZB4LiXuw
Looks like I will write only SignIn function. Other part is not interested for me.
Generating Signature and Sign in function.
Article about swf working with swf shows how to application "crypting" request again bad guys.
and our first Sign in function is look like :
Main problem is understanding a string "JSON_STRING". I've sorted out that this string contains nickname , email, link to photo etc. Everyone can get this string from checking headers procedure, I've informed about this one or two weeks ago. Strings #6-8 print this information. Those string have debuging purpose only. Strings #10-12 are preparing request and sending it to server.
Other server command requires a similar job to our SignIn function.
I have no interest for this and I would like to do something funny and smart (Ex: Arduino or AI )