From 1fac7e685a032c843217429f015e57770bfa6c43 Mon Sep 17 00:00:00 2001 From: Yuri Baburov Date: Mon, 27 Apr 2015 14:35:00 +0600 Subject: [PATCH] Added a feature to allow more images per article (with a test) --- readability/readability.py | 2 +- tests/samples/too-many-images.sample.html | 2154 +++++++++++++++++++++ tests/test_article_only.py | 7 + 3 files changed, 2162 insertions(+), 1 deletion(-) create mode 100644 tests/samples/too-many-images.sample.html diff --git a/readability/readability.py b/readability/readability.py index fcbab77..680505a 100755 --- a/readability/readability.py +++ b/readability/readability.py @@ -482,7 +482,7 @@ class Document: #if el.tag == 'div' and counts["img"] >= 1: # continue - if counts["p"] and counts["img"] > counts["p"]: + if counts["p"] and counts["img"] > 1+counts["p"]*1.3: reason = "too many images (%s)" % counts["img"] to_remove = True elif counts["li"] > counts["p"] and tag != "ul" and tag != "ol": diff --git a/tests/samples/too-many-images.sample.html b/tests/samples/too-many-images.sample.html new file mode 100644 index 0000000..db14745 --- /dev/null +++ b/tests/samples/too-many-images.sample.html @@ -0,0 +1,2154 @@ + + + + + + + + + + + + + + + + + +melposen.blogspot.no: SAFTSENTRIFUGE + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + +
+ +

torsdag 23. februar 2012

+ +
+ +
+
+ + + + +

+SAFTSENTRIFUGE +

+
+
+
+
+Jeg har kjøpt meg en saftsentrifuge, eller jucie maker om du vil. Den er helt fantastisk genial. Frukten (ikke appelsiner og kiwi) bare skylles og puttes rett i maskinen, man trenger ikke skrelle eller fjerne steiner og kjernehus.  5 om dagen har aldri vært så enkelt som nå. Alt bare moses rett ned i maskinen og så får jeg ferskpresset knallgod jucie. Jeg tror vi har hatt mer frukt de siste 2-3 dagene enn de siste 2-3 månedene! Restene som blir til overs ligner på en slags pure, og kan f.eks brukes i kaker eller sauser. Det har jeg ikke testet ut enda, og det blir egentlig ganske lite svinn i forhold til hvor mange frukter man putter oppi.
+
+
+
+
+
+
+
+
+ +
+
+ +

Ingen kommentarer:

+
+
+
+
+
+ +

Legg inn en kommentar

+

+

+ + + + +
+

+ +
+
+ +
+ + +
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/tests/test_article_only.py b/tests/test_article_only.py index 3a8f1c6..c268d3d 100644 --- a/tests/test_article_only.py +++ b/tests/test_article_only.py @@ -37,3 +37,10 @@ class TestArticleOnly(unittest.TestCase): res = doc.summary(html_partial=True) self.assertEqual('