瀏覽代碼

Add download script

main
Adrian Short 6 年之前
父節點
當前提交
e60bd2f163
共有 3 個檔案被更改,包括 36 行新增0 行删除
  1. +2
    -0
      Gemfile
  2. +18
    -0
      Gemfile.lock
  3. +16
    -0
      bin/download

+ 2
- 0
Gemfile 查看文件

@@ -4,3 +4,5 @@ ruby '2.3.1'

gem 'scraperwiki', :git => 'https://github.com/openaustralia/scraperwiki-ruby/', :branch => 'morph_defaults'
gem 'petrify', :git => 'https://github.com/adrianshort/petrify/'
gem 'rest-client'
gem 'json'

+ 18
- 0
Gemfile.lock 查看文件

@@ -17,21 +17,39 @@ GIT
GEM
remote: https://rubygems.org/
specs:
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
haml (5.0.4)
temple (>= 0.8.0)
tilt
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
json (2.1.0)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
netrc (0.11.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
sqlite3 (1.3.13)
sqlite_magic (0.0.6)
sqlite3
temple (0.8.0)
tilt (2.0.8)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)

PLATFORMS
ruby

DEPENDENCIES
json
petrify!
rest-client
scraperwiki!

RUBY VERSION


+ 16
- 0
bin/download 查看文件

@@ -0,0 +1,16 @@
#!/usr/bin/env ruby

require 'scraperwiki'
require 'rest-client'
require 'json'
require 'pp'

morph_api_url = 'https://api.morph.io/adrianshort/inlink-scraper/data.json'

result = RestClient.get(morph_api_url, params: {
key: ENV['MORPH_API_KEY'],
query: "select * from applications"
})
apps = JSON.parse(result)
ScraperWiki.save_sqlite(['authority_name', 'council_reference'], apps, 'applications')

Loading…
取消
儲存