【发布时间】:2011-04-20 23:49:59
【问题描述】:
我正在尝试创建一个脚本,该脚本将登录到drupal,然后能够访问站点上的每个页面。
我遇到的问题是在对站点进行身份验证时......它似乎无法保留 cookie 并将它们用于每个请求,所以我未经授权的 drupal 事情。
http = Net::HTTP.new('www.example.com', 443)
http.use_ssl = true path = '?q=front_page&destination=front_page'
resp, data = http.get(path, nil) cookie = resp.response['set-cookie']
data = '"name=jobbloggs&pass=securepassword&op=Log in&form_id=user_login'
headers = { 'Cookie' => cookie,
'Referer' => 'https://www.example.com/',
'Content-Type' => 'application/x-www-form-urlencoded' }
resp, data = http.post(path, data, headers)
puts data
任何帮助将不胜感激。
【问题讨论】:
标签: ruby-on-rails ruby drupal cookies session-cookies