Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

fix minor error in IBL tests and post-processing nested annoations

Shane Evans407f7f2d65a9
diff --git a/scrapy/contrib/ibl/extractors.py b/scrapy/contrib/ibl/extractors.py
index 41bd4d437..6e2f2c266 100644
--- a/scrapy/contrib/ibl/extractors.py
+++ b/scrapy/contrib/ibl/extractors.py
@@ -163,7 +163,7 @@ def safehtml(region, allowed_tags=_TAGS_TO_KEEP, replace_tags=_TAGS_TO_REPLACE):
def _process_markup(region, textf, tagf):
fragments = getattr(region, 'parsed_fragments', None)
if fragments is None:
- textf(region)
+ yield textf(region)
return
fiter = iter(fragments)
for fragment in fiter:
diff --git a/scrapy/tests/test_contrib_ibl/test_extraction.py b/scrapy/tests/test_contrib_ibl/test_extraction.py
index 3a7bdd393..7b82f7b33 100644
--- a/scrapy/tests/test_contrib_ibl/test_extraction.py
+++ b/scrapy/tests/test_contrib_ibl/test_extraction.py
@@ -249,12 +249,12 @@ SL342
Nice product for ladies
<br/><ins data-scrapy-annotate="{&quot;variant&quot;: 0, &quot;generated&quot;: true,
&quot;annotations&quot;: {&quot;content&quot;: &quot;price&quot;}}">
-&pounds;85.00
+&pound;85.00
</ins>
</p>
<ins data-scrapy-annotate="{&quot;variant&quot;: 0, &quot;generated&quot;: true,
&quot;annotations&quot;: {&quot;content&quot;: &quot;price_before_discount&quot;}}">
-&pounds;100.00
+&pound;100.00
</ins>
</body></html>
"""
@@ -266,9 +266,9 @@ SL342
<br/>
Nice product for ladies
<br/>
-&pounds;85.00
+&pound;85.00
</p>
-&pounds;100.00
+&pound;100.00
</body></html>
"""
@@ -812,9 +812,9 @@ TEST_DATA = [
'special_partial_annotation', [ANNOTATED_PAGE11], EXTRACT_PAGE11, DEFAULT_DESCRIPTOR,
{
'name': [u'SL342'],
- 'description': ['\nSL342\n \nNice product for ladies\n \n&pounds;85.00\n'],
- 'price': [u'&pounds;85.00'],
- 'price_before_discount': [u'&pounds;100.00'],
+ 'description': ['\nSL342\n \nNice product for ladies\n \n&pound;85.00\n'],
+ 'price': [u'\xa385.00'],
+ 'price_before_discount': [u'\xa3100.00'],
}
),
(# with ignore-beneath feature