Nokogiriでスクレイピングする時、open-uriを使ってアクセスすることが多い?みたいだけど、例によって閉鎖環境だと一工夫いるのでメモ。
環境変数にhttp_proxyがセットされていれば見に行くっぽいんだけど、自分の環境では見に行ってくれなかった。
Proxyを通す場合
proxy = ["http://hoge.jp:8888", "user", "password"]
open(url, {:proxy_http_basic_authentication => proxy}).read
Basic認証を通す
certs = ["user", "password"]
open(url, {:http_basic_authentication => certs}).read
両方通す
certs = ["user", "password"]
proxy = ["http://hoge.jp:8888", "user", "password"]
open(url, {:http_basic_authentication => certs,
:proxy_http_basic_authentication => proxy}).read