]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/googlesearch.py
   1 from __future__ 
import unicode_literals
 
   6 from .common 
import SearchInfoExtractor
 
   9 class GoogleSearchIE(SearchInfoExtractor
): 
  10     IE_DESC 
= 'Google Video search' 
  12     IE_NAME 
= 'video.google:search' 
  13     _SEARCH_KEY 
= 'gvsearch' 
  15         'url': 'gvsearch15:python language', 
  17             'id': 'python language', 
  18             'title': 'python language', 
  23     def _get_n_results(self
, query
, n
): 
  24         """Get a specified number of results for a query""" 
  33         for pagenum 
in itertools
.count(): 
  34             webpage 
= self
._download
_webpage
( 
  35                 'http://www.google.com/search', 
  37                 note
='Downloading result page %s' % (pagenum 
+ 1), 
  41                     'start': pagenum 
* 10, 
  45             for hit_idx
, mobj 
in enumerate(re
.finditer( 
  46                     r
'<h3 class="r"><a href="([^"]+)"', webpage
)): 
  49                 if not re
.search(r
'id="vidthumb%d"' % (hit_idx 
+ 1), webpage
): 
  57             if (len(entries
) >= n
) or not re
.search(r
'id="pnnext"', webpage
): 
  58                 res
['entries'] = entries
[:n
]