import os
import sys

if 'page' not in os.environ['QUERY_STRING']:
    with open('info') as f:
        for line in f:
            print("i{}\t".format(line.strip()))
    print("0The source of this script\t/users/bej/wikisummary/wikis
    sys.exit()

import requests
import textwrap
from itertools import chain
headers = {'User-Agent': 'Gopher Wiki Summarizer (by jelle@pingiun.

query = {split[0]: split[1] for split in [entry.split('=') for entr
r = requests.get('https://en.wikipedia.org/w/api.php?action=query&f
key = list(r.json()['query']['pages'].keys())[0]
paragraphs = r.json()['query']['pages'][key]['extract'].replace('==
formatted = [textwrap.wrap(paragraph, drop_whitespace=True) + [''] 
print("\n".join(["i{}\t".format(line) for line in chain.from_iterab
if len(formatted) > 8:
    print("iOutput was too long, full page can be found here\t")
    print("h{}\tURL:https://en.wikipedia.org/wiki/{}".format(query[