No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Use Wikidata to get extra information on politicians.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0
~> 0.42.0
~> 3.0.3
~> 1.22.2

Runtime

 Project Readme

Wikidata::Fetcher

Fetch information useful to EveryPolitician from Wikidata

Installation

Add this line to your application's Gemfile:

gem "wikidata-fetcher", git: "https://github.com/everypolitician/wikidata-fetcher.git"

Usage

require 'wikidata/fetcher'

#------------------------------------------
# Step 1: Get a list of Wikipedia pagenames
#------------------------------------------

# from a Wikipedia page, by XPath
en_names = EveryPolitician::Wikidata.wikipedia_xpath( 
  url: 'https://en.wikipedia.org/wiki/Template:Peruvian_Congress_2011-2016',
  xpath: '//table//td[contains(@class,"navbox-list")]//li//a[not(@class="new")]/@title',
) 

# or from a Wikipedia Category
es_names = WikiData::Category.new( 'CategorĂ­a:Congresistas de PerĂș 2011-2016', 'es').member_titles

# or from a Morph scraper
names = EveryPolitician::Wikidata.morph_wikinames(source: 'tmtmtmtm/tuvalu-parliament-wikipedia', column: 'wikiname')

# or from a SPARQL query
ids = EveryPolitician::Wikidata.sparql('SELECT ?item WHERE { ?item wdt:P39 wd:Q18229570 . }')

#-----------------------------------------------------------
# Step 2: Scrape the data from Wikidata based on these names
#-----------------------------------------------------------

EveryPolitician::Wikidata.scrape_wikidata(names: { en: names })

# NB: this can take multiple lists, and can also output the data as it fetches it:

EveryPolitician::Wikidata.scrape_wikidata(names: {
  es: es_names,
  en: en_names,
}, output: true)

Contributing

  1. Fork it ( https://github.com/everypolitician/wikidata-fetcher/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request