1
在下面的脚本中,我访问了一个网站,它有许多重定向,我需要知道上次重定向的URL /端口。如何解析HTTPClient中的Cookie?
cookie_file = Tempfile.new('cookie_jar.txt')
client.set_cookie_store(cookie_file)
client.set_auth(nil, user, pass)
client.ssl_config.verify_mode = nil
r = client.get(uri, :follow_redirect => true)
r = client.get_content(uri, :follow_redirect => true)
pp client.cookie_manager.jar
看看cookie,我可以从第二个cookie看到这次是https://example.com:65003
。如果我再试一次,那么它将是一个不同的端口。
问题
我如何解析了HTTPClient饼干吗?
[#<HTTP::Cookie:name="ASPSESSIONIDQGDSCTSA",
value="DBEHBGICIKNNIBBMNAMGIMFG", domain="example.com",
for_domain=false, path="/", secure=true, httponly=false, expires=nil,
max_age=nil, created_at=2017-04-12 20:09:58 +0200,
accessed_at=2017-04-12 20:09:58 +0200
origin=https://example.com/bwtem/?follow_redirect=true>,
#<HTTP::Cookie:name="ASPSESSIONIDSGAQARRD",
value="APJDHADDOHENHCCHOLLMAHNJ", domain="example.com",
for_domain=false, path="/", secure=true, httponly=false, expires=nil,
max_age=nil, created_at=2017-04-12 20:09:57 +0200,
accessed_at=2017-04-12 20:09:58 +0200
origin=https://example.com:9000/auth/?id=7C05C91D24C4A798230A29FD28C587F3&target=https://example.com:65003&>]
饼干一般腌制/加密/签名,除非你有秘密,你将无法对其进行解密。 – Anthony
这是我正在寻找的纯文本目标的值。所以问题是如何访问它。 –
你的意思是你想从'origin'的值得到'target'查询参数? – Anthony