Returns the list of search query results from the given service. For service=WIKIPEDIA, this is a single WikipediaArticle or None.
(string, service=GOOGLE, **kwargs)
| 2514 | #--- QUERY ----------------------------------------------------------------------------------------- |
| 2515 | |
| 2516 | def query(string, service=GOOGLE, **kwargs): |
| 2517 | """ Returns the list of search query results from the given service. |
| 2518 | For service=WIKIPEDIA, this is a single WikipediaArticle or None. |
| 2519 | """ |
| 2520 | service = service.lower() |
| 2521 | if service in (GOOGLE, "google", "g"): |
| 2522 | engine = Google |
| 2523 | if service in (YAHOO, "yahoo", "y!"): |
| 2524 | engine = Yahoo |
| 2525 | if service in (BING, "bing"): |
| 2526 | engine = Bing |
| 2527 | if service in (TWITTER, "twitter"): |
| 2528 | engine = Twitter |
| 2529 | if service in (FACEBOOK, "facebook", "fb"): |
| 2530 | engine = Facebook |
| 2531 | if service in (WIKIA, "wikia"): |
| 2532 | engine = Wikia |
| 2533 | if service in (WIKIPEDIA, "wikipedia", "wp"): |
| 2534 | engine = Wikipedia |
| 2535 | if service in (FLICKR, "flickr"): |
| 2536 | engine = Flickr |
| 2537 | try: |
| 2538 | kw = {} |
| 2539 | for a in ("license", "throttle", "language"): |
| 2540 | if a in kwargs: |
| 2541 | kw[a] = kwargs.pop(a) |
| 2542 | return engine(kw).search(string, **kwargs) |
| 2543 | except UnboundLocalError: |
| 2544 | raise SearchEngineError, "unknown search engine '%s'" % service |
| 2545 | |
| 2546 | #--- WEB SORT -------------------------------------------------------------------------------------- |
| 2547 |