Created
June 2, 2015 22:32
-
-
Save oncomouse/d75b2b3df81b93772f7c to your computer and use it in GitHub Desktop.
Using Mechanize to Populate Neatline w/ Geocoded Information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location | date | type | point | lat | lon | voyage | |
---|---|---|---|---|---|---|---|
12 Fulton St, New York, NY | 10/19/1843 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 0 | |
Merseyside L3 4BB, Liverpool, UK | 11/1/1843 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 0 | |
Bristol Harbour, Bristol, England | 4/8/1838 | Shipyard Location | POINT(-290859.72885313287 6701227.851099645) | 51.44969200000001 | -2.6128374 | 0 | |
Merseyside L3 4BB, Liverpool, UK | 1/4/1845 | Port of Embarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 1 | |
Boston, MA | 1/24/1845 | Port of Disembarkation | POINT(-7910238.3479711665 5215071.602551562) | 42.3600825 | -71.0588801 | 1 | |
Bay of Quick, Greenock, Scotland | 1/4/1845 | Shipyard Location | POINT(-531214.7175602124 7549756.132135566) | 55.95647599999999 | -4.771983 | 1 | |
12 Fulton St, New York, NY | 6/27/1855 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 2 | |
Merseyside L3 4BB, Liverpool, UK | 7/10/1855 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 2 | |
Stanton and Houston Street, NYC | 4/27/1850 | Shipyard Location | POINT(-8236035.75466465 4971410.872531043) | 40.7219188 | -73.985568 | 2 | |
Merseyside L3 4BB, Liverpool, UK | 6/12/1858 | Port of Embarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 3 | |
12 Fulton St, New York, NY | 6/22/1858 | Port of Disembarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 3 | |
Govan Old Yard, Govan, Scotland | 1/26/1856 | Shipyard Location | POINT(-486549.7979003611 7533304.982698183) | 55.87365519999999 | -4.3707512 | 3 | |
12 Fulton St, New York, NY | 10/8/1859 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 4 | |
Le Havre, FR | 10/20/1859 | Port of Disembarkation | POINT(12014.60132015478 6359165.778041243) | 49.49437 | 0.107929 | 4 | |
Greenpoint, Brooklyn, NYC | 5/5/1857 | Shipyard Location | POINT(-8231170.235757583 4971796.591762957) | 40.7245448 | -73.9418603 | 4 | |
Le Havre, FR | 9/11/1860 | Port of Embarkation | POINT(12014.60132015478 6359165.778041243) | 49.49437 | 0.107929 | 5 | |
12 Fulton St, New York, NY | 9/24/1860 | Port of Disembarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 5 | |
12th St, Manhattan, NYC | 11/23/1857 | Shipyard Location | POINT(-8235808.384604737 4972598.557517067) | 40.7300043 | -73.9835255 | 5 | |
12 Fulton St, New York, NY | 2/17/1869 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 6 | |
Merseyside L3 4BB, Liverpool, UK | 2/27/1869 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 6 | |
Govan East Yard, Govan, Scotland | 3/15/1862 | Shipyard Location | POINT(-480615.02188852546 7531293.290526007) | 55.8635155 | -4.3174382 | 6 | |
Merseyside L3 4BB, Liverpool, UK | 4/30/1870 | Port of Embarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 7 | |
12 Fulton St, New York, NY | 5/10/1870 | Port of Disembarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 7 | |
Govan East Yard, Govan, Scotland | 5/10/1862 | Shipyard Location | POINT(-480615.02188852546 7531293.290526007) | 55.8635155 | -4.3174382 | 7 | |
12 Fulton St, New York, NY | 5/11/1872 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 8 | |
Merseyside L3 4BB, Liverpool, UK | 5/21/1872 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 8 | |
Clyde Bank Iron Shipyard, Cessnock, Govan | 9/27/1870 | Shipyard Location | POINT(-480108.39575404674 7530910.006246075) | 55.8615833 | -4.3128871 | 8 | |
Merseyside L3 4BB, Liverpool, UK | 8/24/1874 | Port of Embarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 9 | |
Boston, MA | 9/1/1874 | Port of Disembarkation | POINT(-7910238.3479711665 5215071.602551562) | 42.3600825 | -71.0588801 | 9 | |
Clyde Bank Iron Shipyard, Cessnock, Govan | 5/1/1860 | Shipyard Location | POINT(-480108.39575404674 7530910.006246075) | 55.8615833 | -4.3128871 | 9 | |
12 Fulton St, New York, NY | 10/20/1875 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 10 | |
Merseyside L3 4BB, Liverpool, UK | 10/29/1875 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 10 | |
New Clyde Bank Iron Shipyard, Clydebank, Scotland | 8/8/1874 | Shipyard Location | POINT(-490337.1986711953 7538553.841790102) | 55.900099 | -4.404774 | 10 | |
Merseyside L3 4BB, Liverpool, UK | 10/20/1881 | Port of Embarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 11 | |
Quebec, QC | 10/29/1881 | Port of Disembarkation | POINT(-7930711.772305103 5910023.688072596) | 46.8032826 | -71.242796 | 11 | |
Govan East Yard, Govan, Scotland | 3/10/1881 | Shipyard Location | POINT(-480615.02188852546 7531293.290526007) | 55.8635155 | -4.3174382 | 11 | |
12 Fulton St, New York, NY | 5/10/1882 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 12 | |
Cobh, IR | 5/18/1882 | Port of Disembarkation | POINT(-923913.924828691 6772823.579843434) | 51.84875 | -8.29966 | 12 | |
New Clyde Bank Iron Shipyard, Clydebank, Scotland | 4/5/1879 | Shipyard Location | POINT(-490337.1986711953 7538553.841790102) | 55.900099 | -4.404774 | 12 | |
Southampton SO14 3QN, Southampton, UK | 12/12/1882 | Port of Embarkation | POINT(-155743.05864967365 6602746.035825983) | 50.8950262 | -1.3990637 | 13 | |
12 Fulton St, New York, NY | 12/21/1882 | Port of Disembarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 13 | |
Fairfield, Govan, Scotland | 10/12/1882 | Shipyard Location | POINT(-480952.14183439687 7531073.636665502) | 55.8624082 | -4.3204666 | 13 | |
12 Fulton St, New York, NY | 8/22/1883 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 14 | |
Merseyside L3 4BB, Liverpool, UK | 8/29/1883 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 14 | |
New Clyde Bank Iron Shipyard, Clydebank, Scotland | 11/26/1881 | Shipyard Location | POINT(-490337.1986711953 7538553.841790102) | 55.900099 | -4.404774 | 14 | |
Southampton SO14 3QN, Southampton, UK | 8/24/1904 | Port of Embarkation | POINT(-155743.05864967365 6602746.035825983) | 50.8950262 | -1.3990637 | 15 | |
Hoboken, NJ | 8/30/1904 | Port of Disembarkation | POINT(-8241244.905707801 4974653.341404914) | 40.7439905 | -74.0323626 | 15 | |
Bredow, Germany | 4/14/1903 | Shipyard Location | POINT(1439242.2044641597 6906774.324931041) | 52.5859511 | 12.9289327 | 15 | |
Boston, MA | 7/5/1905 | Port of Embarkation | POINT(-7910238.3479711665 5215071.602551562) | 42.3600825 | -71.0588801 | 16 | |
Merseyside L3 4BB, Liverpool, UK | 7/13/1905 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 16 | |
Wallsend, Tyne and Wear, England | 4/14/1900 | Shipyard Location | POINT(-170249.24620826388 7360218.9385359185) | 54.991512 | -1.529375 | 16 | |
Merseyside L3 4BB, Liverpool, UK | 8/12/1910 | Port of Embarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 17 | |
Quebec, QC | 8/18/1910 | Port of Disembarkation | POINT(-7930711.772305103 5910023.688072596) | 46.8032826 | -71.242796 | 17 | |
Fairfield, Govan, Scotland | 5/5/1906 | Shipyard Location | POINT(-480952.14183439687 7531073.636665502) | 55.8624082 | -4.3204666 | 17 | |
12 Fulton St, New York, NY | 8/2/1911 | Port of Embarkation | POINT(-8238040.262471187 4969156.247075499) | 40.7065671 | -74.0035748 | 18 | |
Merseyside L3 4BB, Liverpool, UK | 8/8/1911 | Port of Disembarkation | POINT(-333333.99225396814 7057466.066808143) | 53.400715 | -2.9943902 | 18 | |
Wallsend, Tyne and Wear, England | 11/16/1907 | Shipyard Location | POINT(-170249.24620826388 7360218.9385359185) | 54.991512 | -1.529375 | 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mechanize' | |
require 'csv' | |
agent = Mechanize.new {|a| | |
a.user_agent_alias = 'Mac Safari' | |
} | |
agent.get('http://localhost:8888/omeka/admin/') do |page| | |
omeka_page = page.form_with(:action => '/omeka/admin/users/login') do |form| | |
form.username = 'username' | |
form.password = 'password' | |
end.submit | |
CSV.foreach('./points.csv', :headers => true) do |line| | |
# add logic to fill out form | |
# click on items | |
item_page = agent.click(omeka_page.link_with(:text => %r/Items/)) | |
# click on add items | |
add_item_page = agent.click(item_page.link_with(:text => %r/Add an Item/)) | |
# Add the item to the form | |
add_item_page.form_with(:method => 'POST') do |item_form| | |
item_form['public'] = 1 | |
item_form.checkbox_with(:name => 'public').check | |
item_form['Elements[50][0][text]'] = "#{line["location"]}" | |
item_form.add_field!('Elements[38][0][zoom]',10) | |
item_form.add_field!('Elements[38][0][mapon]',1) | |
item_form.add_field!('Elements[38][0][html]',0) | |
item_form.add_field!('Elements[38][0][free]',"") | |
item_form.add_field!('Elements[38][0][geo]',line["point"]) | |
item_form.add_field!('Elements[38][0][base_layer]',"osm") | |
item_form.add_field!('Elements[38][0][center_lon]',line["point"].gsub("POINT(","").gsub(")","").split(" ").first) | |
item_form.add_field!('Elements[38][0][center_lat]',line["point"].gsub("POINT(","").gsub(")","").split(" ").last) | |
item_form.add_field!('Elements[38][0][text]',"#{line["point"]}|10|#{line["point"].gsub("POINT(","").gsub(")","").split(" ").first}|#{line["point"].gsub("POINT(","").gsub(")","").split(" ").last}|osm") | |
item_form['Elements[40][0][text]'] = line["date"] | |
item_form['Elements[48][0][text]'] = line["voyage"] | |
item_form['Elements[51][0][text]'] = line["type"] | |
end.submit | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment