Skip to content

Instantly share code, notes, and snippets.

@whym
Last active May 30, 2016 11:07
Show Gist options
  • Save whym/bb749ec928636bb2f9d468660883961f to your computer and use it in GitHub Desktop.
Save whym/bb749ec928636bb2f9d468660883961f to your computer and use it in GitHub Desktop.
Add interwiki links to pages in a given CSV list
#! /usr/bin/python3
import pandas as pd
import os
import sys
sys.path.append(os.environ['PWB'])
from scripts import interwiki
import pywikibot
def mygen(target):
site = pywikibot.Site()
df = pd.read_csv(target)
for t in df.page_title:
yield pywikibot.Page(site, t)
if __name__ == '__main__':
args = ['-dir:%s/.pywikibot' % os.environ['HOME'],
'-lang:ja',
'-family:wiktionary',
'-user:Whymbot',
'-wiktionary',
'-autonomous',
'-async',
'-query:500',
'-putthrottle:60']
args = pywikibot.handle_args(args)
for arg in args:
interwiki.globalvar.readOptions(arg)
bot = interwiki.InterwikiBot()
#gen = mygen('https://quarry.wmflabs.org/run/87568/output/0/csv?download=true')
gen = mygen('q.csv')
bot.setPageGenerator(iter(gen))
bot.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment