のような偉大な、他の人の作品を見つけるのウェブベースのAPIとRubyのために、私はそれは難しい私は一つの特定の必要性のためのAPIに掘ることを見つけます。そのため、私は保護されたGoogleマップ上のマーカーの座標を収集するための短いウォーター・ウェブ・ドライバー・スクリプトを作成しました。結果ファイルは、ナビゲーションデバイス用のspeedcamファイルを作成するpythonスクリプトで使用されます。
この場合、ラトビア警察によってspeedcamマップが維持管理され更新されていますが、このスクリプトはurlを置き換えるだけですべてのGoogleマップで使用できます。
# encoding: utf-8
require "rubygems"
require "watir-webdriver"
@b = Watir::Browser.new :ff
#--------------------------------
@b.goto "http://maps.google.com/maps?source=s_q&f=q&hl=lv&geocode=&q=htt%2F%2Fmaps.google.com%2Fmaps%2Fms%3Fmsid%3D207561992958290099079.0004b731f1c645294488e%26msa%3D0%26output%3Dkml&aq=&sll=56.799934,24.5753&sspn=3.85093,8.64624&ie=UTF8&ll=56.799934,24.5753&spn=3.610137,9.887695&z=7&vpsrc=0&oi=map_misc&ct=api_logo"
@b.div(:id, "kmlfolders").wait_until_present
all_markers = @b.div(:id, "kmlfolders").divs(:class, "fdrlt")
@prev_coordinates = 1
puts "#{all_markers.length} speedcam markers detected"
File.open("list_of_coordinates.txt","w") do |outfile|
all_markers.each do |marker|
sleep 1
marker.click
sleep 1
description = @b.div(:id => "iw_kml").text
@b.span(:class, "actbar-text").click
sleep 2
coordinates = @b.text_field(:name, "daddr").value
redo if coordinates == @prev_coordinates
puts coordinates
outfile.puts coordinates
@prev_coordinates = coordinates
end
end
puts "Coordinates saved in file!"
@b.close
Mac OSX 10.7およびWindows7の両方で動作します。
Google Maps API - http://code.google.com/apis/maps/documentation/webservices/ - より簡単で効果的です(推測すると、私はそれを試したことはありません)。 –
あなたはそれをやり遂げたでしょう。より簡単で堅牢なものを探しているなら、GM APIが道のりです。 –
HTMLのサンプルがあれば、他の情報が存在するかどうかを確認することができます –