0

I found a neat Ruby script to sum all purchases done on Amazon.de (no other stores like US) for a given year: https://github.com/pwaldhauer/amazon-account-crawler

After installing Ruby and the necessary Ruby Gems Highline and Mechanize I'm able to run the script. But unfortunately I'm behind a proxy server so the script fails with a "Timeout" error.

I read a lot but didn't found out how to use a proxy server. I tried to "set" a HTTP_PROXY environment variable, but still get errors. I also used the following call:

agent.set_proxy('127.0.0.1', '3128')

But this didn't worked out as well. I have the feeling that the HTTP proxy worked but after the login Amazon uses HTTPS and this fails. Can someone tell me a simple way how to tell Mechanize to use a HTTP and HTTPS proxy server?

1
  • You can use github.com/apenwarr/sshuttle to make the whole device you are using runs via ssh tunnle. Really easy to use. Give it a shot. Commented Feb 3, 2012 at 8:58

1 Answer 1

2

There is a known issue with mechanize https and proxies, you will need to use an older version (1.0.0) to get it to work. Also the port should be a number not a string.

Sign up to request clarification or add additional context in comments.

8 Comments

How to install this old version? I tried with gem install mechanize 1.0.0 but there is no such "gem" in the repository.
gem install mechanize -v=1.0.0
Thanks a lot, that worked but now there is a different error: C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize 1.0.0/lib/mechanize/form.rb:136:in 'method_missing': undefined method 'id' for #<Mechanize::Form:0x12c51f0> (NoMethodError) from (eval):4:in 'block (2 levels) in forms_with' I don't know if this is still a connection problem or if I need to rewrite the script to use mechanize version 1.0.
try using name instead of id, or just forms[0] if it's the first one.
It worked for the login form, thanks. Unfortunately there is a dropdown box, which has no "name" field: select_form = orders_page.form_with(:id => 'order-dropdown-form') This is the HTML source from Amazon: <form id="order-dropdown-form" action="/gp/css/history/orders/view.html/ref=ohfilter_C" method="get"> <input type="hidden" name="opt" value="ab">
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.