Search code examples
rubymechanize-ruby

Mechanize Ruby: Print Cookies


When I do agent.get(URL) I get blank results while when I access the URL directly I can see the results. Is it because some cookies are passed to the result page? Can you please help me to print cookies before agent.get(URL) so that I will know what is being passed?


Solution

  • I could solve this by adding the cookies before submitting the form.

    agent = Mechanize.new
    cookie = Mechanize::Cookie.new(name: '#{name}', value: '#{value}', domain: '#{domain}', path: '/')
    agent.cookie_jar.add(cookie)