]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/googlesearch.py
21c240e512b6c544efa616d95fcb1b0a76865a8a
4 from .common
import SearchInfoExtractor
10 class GoogleSearchIE(SearchInfoExtractor
):
11 """Information Extractor for Google Video search queries."""
12 _MORE_PAGES_INDICATOR
= r
'id="pnnext" class="pn"'
14 IE_NAME
= u
'video.google:search'
15 _SEARCH_KEY
= 'gvsearch'
17 def _get_n_results(self
, query
, n
):
18 """Get a specified number of results for a query"""
26 for pagenum
in itertools
.count(1):
27 result_url
= u
'http://www.google.com/search?tbm=vid&q=%s&start=%s&hl=en' % (compat_urllib_parse
.quote_plus(query
), pagenum
*10)
28 webpage
= self
._download
_webpage
(result_url
, u
'gvsearch:' + query
,
29 note
='Downloading result page ' + str(pagenum
))
31 for mobj
in re
.finditer(r
'<h3 class="r"><a href="([^"]+)"', webpage
):
36 res
['entries'].append(e
)
38 if (pagenum
* 10 > n
) or not re
.search(self
._MORE
_PAGES
_INDICATOR
, webpage
):