|
@@ -39,19 +39,24 @@ class TestYahooNewsEngine(SearxTestCase):
|
39
|
39
|
self.assertEqual(yahoo_news.response(response), [])
|
40
|
40
|
|
41
|
41
|
html = """
|
42
|
|
- <div class="res">
|
43
|
|
- <div>
|
44
|
|
- <h3>
|
45
|
|
- <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
46
|
|
- This is
|
47
|
|
- the <b>title</b>...
|
48
|
|
- </a>
|
49
|
|
- </h3>
|
50
|
|
- </div>
|
51
|
|
- <span class="url">Business via Yahoo! Finance</span> <span class="timestamp">Feb 03 09:45am</span>
|
52
|
|
- <div class="abstr">
|
53
|
|
- This is the content
|
54
|
|
- </div>
|
|
42
|
+ <ol class=" reg searchCenterMiddle">
|
|
43
|
+ <li class="first">
|
|
44
|
+ <div class="compTitle">
|
|
45
|
+ <h3>
|
|
46
|
+ <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
47
|
+ This is
|
|
48
|
+ the <b>title</b>...
|
|
49
|
+ </a>
|
|
50
|
+ </h3>
|
|
51
|
+ </div>
|
|
52
|
+ <div>
|
|
53
|
+ <span class="cite">Business via Yahoo!</span>
|
|
54
|
+ <span class="tri fc-2nd ml-10">May 01 10:00 AM</span>
|
|
55
|
+ </div>
|
|
56
|
+ <div class="compText">
|
|
57
|
+ This is the content
|
|
58
|
+ </div>
|
|
59
|
+ </li>
|
55
|
60
|
</div>
|
56
|
61
|
"""
|
57
|
62
|
response = mock.Mock(text=html)
|
|
@@ -63,48 +68,59 @@ class TestYahooNewsEngine(SearxTestCase):
|
63
|
68
|
self.assertEqual(results[0]['content'], 'This is the content')
|
64
|
69
|
|
65
|
70
|
html = """
|
66
|
|
- <div class="res">
|
67
|
|
- <div>
|
68
|
|
- <h3>
|
69
|
|
- <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
70
|
|
- This is
|
71
|
|
- the <b>title</b>...
|
72
|
|
- </a>
|
73
|
|
- </h3>
|
74
|
|
- </div>
|
75
|
|
- <span class="url">Business via Yahoo!</span> <span class="timestamp">2 hours, 22 minutes ago</span>
|
76
|
|
- <div class="abstr">
|
77
|
|
- This is the content
|
78
|
|
- </div>
|
79
|
|
- </div>
|
80
|
|
- <div class="res">
|
81
|
|
- <div>
|
82
|
|
- <h3>
|
83
|
|
- <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
84
|
|
- This is
|
85
|
|
- the <b>title</b>...
|
86
|
|
- </a>
|
87
|
|
- </h3>
|
88
|
|
- </div>
|
89
|
|
- <span class="url">Business via Yahoo!</span> <span class="timestamp">22 minutes ago</span>
|
90
|
|
- <div class="abstr">
|
91
|
|
- This is the content
|
92
|
|
- </div>
|
93
|
|
- </div>
|
94
|
|
- <div class="res">
|
95
|
|
- <div>
|
96
|
|
- <h3>
|
97
|
|
- <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
98
|
|
- This is
|
99
|
|
- the <b>title</b>...
|
100
|
|
- </a>
|
101
|
|
- </h3>
|
102
|
|
- </div>
|
103
|
|
- <span class="url">Business via Yahoo!</span> <span class="timestamp">Feb 03 09:45am 1900</span>
|
104
|
|
- <div class="abstr">
|
105
|
|
- This is the content
|
106
|
|
- </div>
|
107
|
|
- </div>
|
|
71
|
+ <ol class=" reg searchCenterMiddle">
|
|
72
|
+ <li class="first">
|
|
73
|
+ <div class="compTitle">
|
|
74
|
+ <h3>
|
|
75
|
+ <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
76
|
+ This is
|
|
77
|
+ the <b>title</b>...
|
|
78
|
+ </a>
|
|
79
|
+ </h3>
|
|
80
|
+ </div>
|
|
81
|
+ <div>
|
|
82
|
+ <span class="cite">Business via Yahoo!</span>
|
|
83
|
+ <span class="tri fc-2nd ml-10">2 hours, 22 minutes ago</span>
|
|
84
|
+ </div>
|
|
85
|
+ <div class="compText">
|
|
86
|
+ This is the content
|
|
87
|
+ </div>
|
|
88
|
+ </li>
|
|
89
|
+ <li>
|
|
90
|
+ <div class="compTitle">
|
|
91
|
+ <h3>
|
|
92
|
+ <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
93
|
+ This is
|
|
94
|
+ the <b>title</b>...
|
|
95
|
+ </a>
|
|
96
|
+ </h3>
|
|
97
|
+ </div>
|
|
98
|
+ <div>
|
|
99
|
+ <span class="cite">Business via Yahoo!</span>
|
|
100
|
+ <span class="tri fc-2nd ml-10">22 minutes ago</span>
|
|
101
|
+ </div>
|
|
102
|
+ <div class="compText">
|
|
103
|
+ This is the content
|
|
104
|
+ </div>
|
|
105
|
+ </li>
|
|
106
|
+ <li>
|
|
107
|
+ <div class="compTitle">
|
|
108
|
+ <h3>
|
|
109
|
+ <a class="yschttl spt" href="http://this.is.the.url" target="_blank">
|
|
110
|
+ This is
|
|
111
|
+ the <b>title</b>...
|
|
112
|
+ </a>
|
|
113
|
+ </h3>
|
|
114
|
+ </div>
|
|
115
|
+ <div>
|
|
116
|
+ <span class="cite">Business via Yahoo!</span>
|
|
117
|
+ <span class="tri fc-2nd ml-10">Feb 03 09:45AM 1900</span>
|
|
118
|
+ </div>
|
|
119
|
+ <div class="compText">
|
|
120
|
+ This is the content
|
|
121
|
+ </div>
|
|
122
|
+ </li>
|
|
123
|
+ </ol>
|
108
|
124
|
"""
|
109
|
125
|
response = mock.Mock(text=html)
|
110
|
126
|
results = yahoo_news.response(response)
|
|
@@ -114,30 +130,3 @@ class TestYahooNewsEngine(SearxTestCase):
|
114
|
130
|
self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
|
115
|
131
|
self.assertEqual(results[0]['content'], 'This is the content')
|
116
|
132
|
self.assertEqual(results[2]['publishedDate'].year, datetime.now().year)
|
117
|
|
-
|
118
|
|
- html = """
|
119
|
|
- <li class="b_algo" u="0|5109|4755453613245655|UAGjXgIrPH5yh-o5oNHRx_3Zta87f_QO">
|
120
|
|
- <div Class="sa_mc">
|
121
|
|
- <div class="sb_tlst">
|
122
|
|
- <h2>
|
123
|
|
- <a href="http://this.should.be.the.link/" h="ID=SERP,5124.1">
|
124
|
|
- <strong>This</strong> should be the title</a>
|
125
|
|
- </h2>
|
126
|
|
- </div>
|
127
|
|
- <div class="sb_meta">
|
128
|
|
- <cite>
|
129
|
|
- <strong>this</strong>.meta.com</cite>
|
130
|
|
- <span class="c_tlbxTrg">
|
131
|
|
- <span class="c_tlbxH" H="BASE:CACHEDPAGEDEFAULT" K="SERP,5125.1">
|
132
|
|
- </span>
|
133
|
|
- </span>
|
134
|
|
- </div>
|
135
|
|
- <p>
|
136
|
|
- <strong>This</strong> should be the content.</p>
|
137
|
|
- </div>
|
138
|
|
- </li>
|
139
|
|
- """
|
140
|
|
- response = mock.Mock(text=html)
|
141
|
|
- results = yahoo_news.response(response)
|
142
|
|
- self.assertEqual(type(results), list)
|
143
|
|
- self.assertEqual(len(results), 0)
|