diff --git a/finesse/google_search.py b/finesse/google_search.py new file mode 100644 index 0000000..6ed6322 --- /dev/null +++ b/finesse/google_search.py @@ -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 diff --git a/requirements.txt b/requirements.txt index ff525a0..cbdda38 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ locust regex +git+https://github.com/abenassi/Google-Search-API diff --git a/tests/test_google_search.py b/tests/test_google_search.py new file mode 100644 index 0000000..901d99d --- /dev/null +++ b/tests/test_google_search.py @@ -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()