mirror of https://github.com/scrapy/scrapy.git
BaseSgmlLinkExtractor: Fix extract '>>' as '>'
The anchor text is extracted as '>' in <a href="/">>></a> Signed-off-by: Ping Yin <pkufranky@gmail.com>
This commit is contained in:
parent
f41fd3214e
commit
aa86f180b9
|
|
@ -71,8 +71,8 @@ class BaseSgmlLinkExtractor(FixedSGMLParser):
|
|||
self.current_link = None
|
||||
|
||||
def handle_data(self, data):
|
||||
if self.current_link and not self.current_link.text:
|
||||
self.current_link.text = data.strip()
|
||||
if self.current_link:
|
||||
self.current_link.text = self.current_link.text + data.strip()
|
||||
|
||||
def matches(self, url):
|
||||
"""This extractor matches with any url, since
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class LinkExtractorTestCase(unittest.TestCase):
|
|||
<p><a href="/about.html">About us</a></p>
|
||||
<img src="/logo.png" alt="Company logo (not a link)" />
|
||||
<p><a href="../othercat.html">Other category</a></p>
|
||||
<p><a href="/">>></a></p>
|
||||
<p><a href="/" /></p>
|
||||
</body></html>"""
|
||||
response = HtmlResponse("http://example.org/somepage/index.html", body=html)
|
||||
|
|
@ -23,6 +24,7 @@ class LinkExtractorTestCase(unittest.TestCase):
|
|||
[Link(url='http://example.org/somepage/item/12.html', text='Item 12'),
|
||||
Link(url='http://example.org/about.html', text='About us'),
|
||||
Link(url='http://example.org/othercat.html', text='Other category'),
|
||||
Link(url='http://example.org/', text='>>'),
|
||||
Link(url='http://example.org/', text='')])
|
||||
|
||||
def test_base_url(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue