-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #6: abenassi Google-Search-API
- Loading branch information
1 parent
0a55151
commit cdc3f35
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from googleapi import google | ||
|
||
def get_google_search_urls(query: str, num_results: int = 100) -> list[str]: | ||
links = [] | ||
search_results = google.search(query, num_results) | ||
print(search_results[0].google_link ) | ||
links.append(search_results[0].google_link ) | ||
return links |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
locust | ||
regex | ||
git+https://github.com/abenassi/Google-Search-API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import unittest | ||
from finesse.google_search import get_google_search_urls | ||
|
||
class TestGoogleSearch(unittest.TestCase): | ||
def test_get_google_search_urls(self): | ||
query = "Canada Food Inspection Agency" | ||
num_results = 10 | ||
urls = get_google_search_urls(query, num_results) | ||
self.assertEqual(len(urls), num_results) | ||
self.assertTrue(all(url.startswith("http") for url in urls)) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |