Skip to content

Commit

Permalink
Initial scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtmtmtm committed Feb 13, 2017
1 parent d61beee commit 593169b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scraper.rb
@@ -0,0 +1,23 @@
#!/bin/env ruby
# encoding: utf-8
# frozen_string_literal: true

require 'pry'
require 'scraperwiki'
require 'wikidata/fetcher'
require 'wikidata/area'

query = <<QUERY
SELECT DISTINCT ?item ?itemLabel
WHERE
{
?item wdt:P31 wd:Q200547 .
}
QUERY

wanted = EveryPolitician::Wikidata.sparql(query)
raise 'No ids' if wanted.empty?

ScraperWiki.sqliteexecute('DELETE FROM data') rescue nil
data = Wikidata::Areas.new(ids: wanted).data
ScraperWiki.save_sqlite(%i(id), data)

0 comments on commit 593169b

Please sign in to comment.