Skip to content

Commit

Permalink
Add support for r.search.yahoo.com
Browse files Browse the repository at this point in the history
  • Loading branch information
msukmanowsky committed Dec 16, 2014
1 parent 72985c5 commit 9f8310d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions serpextract/serpextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,18 @@ def parse(self, url_parts):
keyword = query[extractor][-1]

# Now we have to check for a tricky case where it is a SERP
# but just with no keyword as can be the case with Google
# Images or DuckDuckGo
# but just with no keyword as can be the case with Google,
# DuckDuckGo or Yahoo!
if keyword is None and extractor == 'q' and \
engine_name in ('Google Images', 'DuckDuckGo'):
keyword = ''
elif keyword is None and extractor == 'q' and \
engine_name == 'Google' and \
_is_url_without_path_query_or_fragment(url_parts):
keyword = ''
elif keyword is None and engine_name == 'Yahoo!' and \
url_parts.netloc.lower() == 'r.search.yahoo.com':
keyword = ''

if keyword is not None:
return ExtractResult(engine_name, keyword, self)
Expand Down
1 change: 1 addition & 0 deletions tests/test_serps.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_yahoo(self):
serps = (
('http://ca.search.yahoo.com/search;_ylt=At9vKXZDJTDsQ6o7bDQPLBUt17V_;_ylc=X1MDMjE0MjYyMzUzMwRfcgMyBGZyA3lmcC10LTcxNQRuX2dwcwMxMARvcmlnaW4DY2EueWFob28uY29tBHF1ZXJ5A2hlbGxvBHNhbwMx?p=hello&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-715', 'Yahoo!', u'hello'),
('http://search.yahoo.com/search;_ylt=AnQcoCW29caK.8RLkGgSiqGbvZx4?p=united+states&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-900', 'Yahoo!', u'united states'),
('http://r.search.yahoo.com/_ylt=A0LEVy5UeJBUUzgAR2FXNyoA;_ylu=X3oDMTEzaGpsYTZuBHNlYwNzcgRwb3MDMgRjb2xvA2JmMQR2dGlkA1ZJUDU1OF8x/RV=2/RE=1418782933/RO=10/RU=http%3a%2f%2fen.wikipedia.org%2fwiki%2fToronto/RK=0/RS=cUOWJ12k59iqbScMA1r6sQedikc-', 'Yahoo!', u''),
)
self.assertValidSERPs(serps)

Expand Down

0 comments on commit 9f8310d

Please sign in to comment.