aboutsummaryrefslogtreecommitdiffstats
path: root/wikisource.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikisource.py')
-rw-r--r--wikisource.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/wikisource.py b/wikisource.py
index 070c84a..1459468 100644
--- a/wikisource.py
+++ b/wikisource.py
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
import requests
-import lxml
import sys
from bs4 import BeautifulSoup
from itertools import takewhile, count
URL = "http://fr.wikisource.org/w/index.php"
+
def get_page(title, page):
- params = { "action": "render", "title": "Page:" + title + "/" + str(page) }
+ params = {"action": "render", "title": "Page:" + title + "/" + str(page)}
r = requests.get(URL, params=params)
if r.status_code == requests.codes.ok:
soup = BeautifulSoup(r.text, "lxml")
@@ -16,9 +16,10 @@ def get_page(title, page):
else:
return None
+
def get_pages(title, begin=1, end=None):
if end:
- return (get_page(title, i) for i in xrange(begin, end+1))
+ return (get_page(title, i) for i in xrange(begin, end + 1))
else:
return takewhile(lambda x: x is not None,
(get_page(title, i) for i in count(begin)))