【发布时间】:2019-04-04 18:33:11
【问题描述】:
我正在尝试将多个 cookie 发送到一个 url,直到我得到正确的一个,但我不知道为什么我当前的代码不起作用
我查看了将 cookie 发送到 url 的现有答案,但它们似乎都不适用于我的情况 代码中的cmets是任务的指令
# Write a script that can guess cookie values
# and send them to the url http://127.0.0.1:8082/cookiestore
# Read the response from the right cookie value to get the flag.
# The cookie id the aliens are using is alien_id
# the id is a number between 1 and 75
import urllib2
req = urllib2.Request('http://127.0.0.1:8082/cookiestore')
for i in range(75):
req.add_header('alien_id', i)
response = urllib2.urlopen(req)
html = response.read()
print(html)
我预计其中一次迭代会打印出不同的东西,但它们都是一样的
【问题讨论】:
-
你找到解决办法了吗?
-
@Miffy 它在下面 ;) 或者至少它对我有用。