1

経緯線 1.0.0.pre2 を使用します。Google が認識しない住所を特定しようとすると、経緯線で例外が発生します。

LibXML::XML::Error in Cms/storesController#update

Fatal error: Extra content at the end of the document at :1.
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/happymapper-0.3.2/lib/happymapper.rb:84:in `parse'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/happymapper-0.3.2/lib/happymapper.rb:84:in `parse'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/google.rb:82:in `prepare_response'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/base.rb:83:in `get'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/google.rb:36:in `locate'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/acts_as_geocodable-1.0.4/lib/acts_as_geocodable/geocode.rb:31:in `create_from_location'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/acts_as_geocodable-1.0.4/lib/acts_as_geocodable/geocode.rb:27:in `find_or_create_by_location'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/acts_as_geocodable-1.0.4/lib/acts_as_geocodable.rb:262:in `attach_geocode'
...
...

Google サービスを使用しています。これは、例外を生成する応答です。

"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><title>Sorry...</title><style> body { font-family: verdana, arial, sans-serif; background-color: #fff; color: #000; }</style></head><body><div><table><tr><td><b><font face=times color=#0039b6 size=10>G</font><font face=times color=#c41200 size=10>o</font><font face=times color=#f3c518 size=10>o</font><font face=times color=#0039b6 size=10>g</font><font face=times color=#30a72f size=10>l</font><font face=times color=#c41200 size=10>e</font></b></td><td style=\"text-align: left; vertical-align: bottom; padding-bottom: 15px; width: 50%\"><div style=\"border-bottom: 1px solid #dfdfdf;\">Sorry...</div></td></tr></table></div><div style=\"margin-left: 4em;\"><h1>We're sorry...</h1><p>... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.</p></div><div style=\"margin-left: 4em;\">See <a href=\"http://www.google.com/support/bin/answer.py?answer=86640\">Google Help</a> for more information.<br/><br/></div><div style=\"text-align: center; border-top: 1px solid #dfdfdf;\">&copy; 2009 Google - <a href=\"http://www.google.com\">Google Home</a></div></body></html>"

他のアドレスでも機能します!どうすればその例外を防ぐことができますか?

4

1 に答える 1

0

この同じエラーを受け取りました。Pry Debugger を使用して、ハッピー マッパーの Parse 宣言の下に binding.pry を配置しました。あなたにとってそれは

/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/happymapper-0.3.2/lib/happymapper.rb:84:in `parse'

こじ開けを再開して走った

location = geocoder.locate("61 East 9th Street, Holland, MI")

デバッガは直後に停止しました

def parse(xml, options = {})

メッセージを含む HTML ダンプを Google から受け取るために、xml 変数のダンプを行いました。

<h1>We're sorry...</h1>
<p>... but your computer or network may be sending automated queries. 
To protect our users, we can't process your request right now.</p>
See <a href="https://support.google.com/websearch/answer/86640">
    Google Help
</a> for more information.

まだ解決していませんが、それが問題です。

于 2013-10-31T23:12:12.643 に答える