diff options
| -rw-r--r-- | compare.py | 6 | ||||
| -rw-r--r-- | wikisource.py | 7 |
2 files changed, 7 insertions, 6 deletions
@@ -15,7 +15,7 @@ l2 = get_page(wikibook, n) print len(l2.split()) l3 = su.simplify(l2) C = su.align(l3.split(), l1, c1) -pdb.set_trace() -sexp = page_sexp(wikibook, n) -su.alignment_to_sexp(C[1], sexp, l2.split()) +#pdb.set_trace() +#sexp = page_sexp(wikibook, n) +#su.alignment_to_sexp(C[1], sexp, l2.split()) su.print_alignment(l2.split(), l1, c1, C[1]) 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))) |
