Training: Programming 1 (Training, Coding)
When we visit the first link gived we will get a message which is a random string, then we have to visit the second URL with the message that we have got from the first url response as the parameter of “answer”, but our timelimit is just 1.337 seconds. Obviously, we cannot complete it manually because of timeout.
In order to prevent timeout, we develop a py script to help us send the get request as well as obtain the response data.
We will use the python module called requests, during the http link, it’s very convenient to set http parameters like cookies:
import requests
url_1 = "http://www.wechall.net/challenge/training/programming1/index.php?action=request"
url_2 = "http://www.wechall.net/challenge/training/programming1/index.php?answer="
user_cookies = {"WC":"12240888-50884-rDsgZ8TJ1JhtRI7s"}
rsp_1 = requests.get(url_1 , cookies = user_cookies)
answer_value = rsp_1.text
print(rsp_1.text)
rsp_2 = requests.get(url_2 + answer_value , cookies = user_cookies, timeout = 1.337)
print(rsp_2.text)
as the following illustration, success! so easy!