0

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?

Mohamed Rafiq P
  • 758
  • 1
  • 7
  • 17
  • Possible duplicate of [How do I print out the cookies that Mechanized has stored?](http://stackoverflow.com/questions/2566287/how-do-i-print-out-the-cookies-that-mechanized-has-stored) – Oleksandr Holubenko Oct 21 '16 at 13:17
  • I tried that but it shows the default cookies and not that cookies set by the form that i am coming from – Mohamed Rafiq P Oct 21 '16 at 13:20
  • Did you check how the page looks in your browser with javascript turned off? – Felix Oct 22 '16 at 19:28

1 Answers1

0

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)
Mohamed Rafiq P
  • 758
  • 1
  • 7
  • 17