WeChall challenge:practice 1

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!
result

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值