Retrievecontentsbot

De Wikipast
Aller à la navigation Aller à la recherche

Extrait le contenu d'une page wiki en wikicode

code

# -*- coding: utf-8 -*-

import requests
from bs4 import BeautifulSoup

baseurl='http://wikipast.epfl.ch/wikipast/'

names=['Henri_Dunant']

for name in names:
    result=requests.post(baseurl+'api.php?action=query&titles='+name+'&export&exportnowrap')
    soup=BeautifulSoup(result.text, "lxml")
    #soup=BeautifulSoup(result.text)
    code=''
    for primitive in soup.findAll("text"):
        code+=primitive.string
    print(code)