|
|
@ -39,19 +39,24 @@ class TestYahooNewsEngine(SearxTestCase):
|
|
|
|
self.assertEqual(yahoo_news.response(response), [])
|
|
|
|
self.assertEqual(yahoo_news.response(response), [])
|
|
|
|
|
|
|
|
|
|
|
|
html = """
|
|
|
|
html = """
|
|
|
|
<div class="res">
|
|
|
|
<ol class=" reg searchCenterMiddle">
|
|
|
|
<div>
|
|
|
|
<li class="first">
|
|
|
|
<h3>
|
|
|
|
<div class="compTitle">
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
<h3>
|
|
|
|
This is
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
the <b>title</b>...
|
|
|
|
This is
|
|
|
|
</a>
|
|
|
|
the <b>title</b>...
|
|
|
|
</h3>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</h3>
|
|
|
|
<span class="url">Business via Yahoo! Finance</span> <span class="timestamp">Feb 03 09:45am</span>
|
|
|
|
</div>
|
|
|
|
<div class="abstr">
|
|
|
|
<div>
|
|
|
|
This is the content
|
|
|
|
<span class="cite">Business via Yahoo!</span>
|
|
|
|
</div>
|
|
|
|
<span class="tri fc-2nd ml-10">May 01 10:00 AM</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="compText">
|
|
|
|
|
|
|
|
This is the content
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
response = mock.Mock(text=html)
|
|
|
|
response = mock.Mock(text=html)
|
|
|
@ -63,48 +68,59 @@ class TestYahooNewsEngine(SearxTestCase):
|
|
|
|
self.assertEqual(results[0]['content'], 'This is the content')
|
|
|
|
self.assertEqual(results[0]['content'], 'This is the content')
|
|
|
|
|
|
|
|
|
|
|
|
html = """
|
|
|
|
html = """
|
|
|
|
<div class="res">
|
|
|
|
<ol class=" reg searchCenterMiddle">
|
|
|
|
<div>
|
|
|
|
<li class="first">
|
|
|
|
<h3>
|
|
|
|
<div class="compTitle">
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
<h3>
|
|
|
|
This is
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
the <b>title</b>...
|
|
|
|
This is
|
|
|
|
</a>
|
|
|
|
the <b>title</b>...
|
|
|
|
</h3>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</h3>
|
|
|
|
<span class="url">Business via Yahoo!</span> <span class="timestamp">2 hours, 22 minutes ago</span>
|
|
|
|
</div>
|
|
|
|
<div class="abstr">
|
|
|
|
<div>
|
|
|
|
This is the content
|
|
|
|
<span class="cite">Business via Yahoo!</span>
|
|
|
|
</div>
|
|
|
|
<span class="tri fc-2nd ml-10">2 hours, 22 minutes ago</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="res">
|
|
|
|
<div class="compText">
|
|
|
|
<div>
|
|
|
|
This is the content
|
|
|
|
<h3>
|
|
|
|
</div>
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
</li>
|
|
|
|
This is
|
|
|
|
<li>
|
|
|
|
the <b>title</b>...
|
|
|
|
<div class="compTitle">
|
|
|
|
</a>
|
|
|
|
<h3>
|
|
|
|
</h3>
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
</div>
|
|
|
|
This is
|
|
|
|
<span class="url">Business via Yahoo!</span> <span class="timestamp">22 minutes ago</span>
|
|
|
|
the <b>title</b>...
|
|
|
|
<div class="abstr">
|
|
|
|
</a>
|
|
|
|
This is the content
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div class="res">
|
|
|
|
<span class="cite">Business via Yahoo!</span>
|
|
|
|
<div>
|
|
|
|
<span class="tri fc-2nd ml-10">22 minutes ago</span>
|
|
|
|
<h3>
|
|
|
|
</div>
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
<div class="compText">
|
|
|
|
This is
|
|
|
|
This is the content
|
|
|
|
the <b>title</b>...
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</h3>
|
|
|
|
<li>
|
|
|
|
</div>
|
|
|
|
<div class="compTitle">
|
|
|
|
<span class="url">Business via Yahoo!</span> <span class="timestamp">Feb 03 09:45am 1900</span>
|
|
|
|
<h3>
|
|
|
|
<div class="abstr">
|
|
|
|
<a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
|
|
This is the content
|
|
|
|
This is
|
|
|
|
</div>
|
|
|
|
the <b>title</b>...
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<span class="cite">Business via Yahoo!</span>
|
|
|
|
|
|
|
|
<span class="tri fc-2nd ml-10">Feb 03 09:45AM 1900</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="compText">
|
|
|
|
|
|
|
|
This is the content
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ol>
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
response = mock.Mock(text=html)
|
|
|
|
response = mock.Mock(text=html)
|
|
|
|
results = yahoo_news.response(response)
|
|
|
|
results = yahoo_news.response(response)
|
|
|
@ -114,30 +130,3 @@ class TestYahooNewsEngine(SearxTestCase):
|
|
|
|
self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
|
|
|
|
self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
|
|
|
|
self.assertEqual(results[0]['content'], 'This is the content')
|
|
|
|
self.assertEqual(results[0]['content'], 'This is the content')
|
|
|
|
self.assertEqual(results[2]['publishedDate'].year, datetime.now().year)
|
|
|
|
self.assertEqual(results[2]['publishedDate'].year, datetime.now().year)
|
|
|
|
|
|
|
|
|
|
|
|
html = """
|
|
|
|
|
|
|
|
<li class="b_algo" u="0|5109|4755453613245655|UAGjXgIrPH5yh-o5oNHRx_3Zta87f_QO">
|
|
|
|
|
|
|
|
<div Class="sa_mc">
|
|
|
|
|
|
|
|
<div class="sb_tlst">
|
|
|
|
|
|
|
|
<h2>
|
|
|
|
|
|
|
|
<a href="http://this.should.be.the.link/" h="ID=SERP,5124.1">
|
|
|
|
|
|
|
|
<strong>This</strong> should be the title</a>
|
|
|
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="sb_meta">
|
|
|
|
|
|
|
|
<cite>
|
|
|
|
|
|
|
|
<strong>this</strong>.meta.com</cite>
|
|
|
|
|
|
|
|
<span class="c_tlbxTrg">
|
|
|
|
|
|
|
|
<span class="c_tlbxH" H="BASE:CACHEDPAGEDEFAULT" K="SERP,5125.1">
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
<strong>This</strong> should be the content.</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
response = mock.Mock(text=html)
|
|
|
|
|
|
|
|
results = yahoo_news.response(response)
|
|
|
|
|
|
|
|
self.assertEqual(type(results), list)
|
|
|
|
|
|
|
|
self.assertEqual(len(results), 0)
|
|
|
|
|
|
|
|