[#48875] MechanizeでNAVERへの自動loginスクリプトでpasswordがうまく渡らない — Takahiro Yamaguchi <Takahiro.Yamaguchi@...>

9 messages 2012/08/08

[#48876] ツイートの文字コード変換について — konoki-nannoki-ggrks.mp4@...

こんにちは。

9 messages 2012/08/08

[#48895] rvmで、1.8.7と1.9.2の両方を使い分けたいのですが — Fumiaki Sakamoto <ua6ta6@...>

お世話になっております。

10 messages 2012/08/13

[ruby-list:48870] [質問] /usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: Name or service not known (SocketError)

From: Takahiro Yamaguchi <Takahiro.Yamaguchi@...>
Date: 2012-08-07 00:53:47 UTC
List: ruby-list #48870
山口と申します。

yama@roswell:~/tmp$ uname -a
Linux roswell 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:50:42 UTC 2011 i686 i686 i386 GNU/Linux
yama@roswell:~/tmp$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

の環境で、mechanize v2.5.1-9 GUIDE.rdocに記載されている
== Let's Fetch a Page! のサンプルコード

yama@roswell:~/tmp$ cat Google.rb
require 'rubygems'
require 'mechanize'

agent = Mechanize.new
page = agent.get('http://google.com/')

を、動作させたところ、

yama@roswell:~/tmp$ ruby Google.rb
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: Name or service not known (SocketError)
        from /usr/lib/ruby/1.8/net/http.rb:560:in `open'
        from /usr/lib/ruby/1.8/net/http.rb:560:in `connect'
        from /usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
        from /usr/lib/ruby/1.8/timeout.rb:101:in `timeout'
        from /usr/lib/ruby/1.8/net/http.rb:560:in `connect'
        from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
        from /usr/lib/ruby/1.8/net/http.rb:548:in `start'
        from /usr/lib/ruby/1.8/mechanize.rb:527:in `fetch_page'
        from /usr/lib/ruby/1.8/mechanize.rb:259:in `get'
        from Google.rb:5

となり、動作しません。

社内からのアクセスのため、proxyの設定を忘れていたので、
http://d.hatena.ne.jp/takatoh/20070522/http_proxy
を参考に、

yama@roswell:~/tmp$ export HTTP_PROXY=http://proxy.company.co.jp:10080/
yama@roswell:~/tmp$ ruby Google.rb
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: Name or service not known (SocketError)
...
yama@roswell:~/tmp$ export HTTP_PROXY=http://proxy.company.co.jp:10080
yama@roswell:~/tmp$ ruby Google.rb
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: Name or service not known (SocketError)
...
yama@roswell:~/tmp$ set http_proxy=http://proxy.company.co.jp:10080/
yama@roswell:~/tmp$ ruby Google.rb
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: Name or service not known (SocketError)
...

いろいろ試みましたが、症状は変わらずです。

解決策をご教示いただけないでしょうか?
よろしくお願いします。

ちなみに、wget は正しく動作する環境です。

yama@roswell:/tmp$ wget http://www.google.com
--2012-08-07 09:45:39--  http://www.google.com/
proxy.company.co.jp をDNSに問いあわせています... aaaa:bbb:0:161::14, ccc.ddd.66.14
proxy.company.co.jp|aaaa:bbb:0:161::14|:10080 に接続しています... 接続しました。
Proxy による接続要求を送信しました、応答を待っています... 302 Found
場所: http://www.google.co.jp/ [続く]
--2012-08-07 09:45:39--  http://www.google.co.jp/
proxy.company.co.jp|aaaa:bbb:0:161::14|:10080 に接続しています... 接続しました。
Proxy による接続要求を送信しました、応答を待っています... 200 OK
長さ: 特定できません [text/html]
`index.html.1' に保存中

    [ <=>                                                                                                         ] 13,403      --.-K/s   時間 0.004s

2012-08-07 09:45:39 (2.86 MB/s) - `index.html.1' へ保存終了 [13403]

-- 
Takahiro Yamaguchi

In This Thread

Prev Next