Skip to content

Commit

Permalink
issue #6: abenassi Google-Search-API
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahim-kabir committed Mar 22, 2024
1 parent 0a55151 commit cdc3f35
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions finesse/google_search.py
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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
locust
regex
git+https://github.com/abenassi/Google-Search-API
13 changes: 13 additions & 0 deletions tests/test_google_search.py
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()

0 comments on commit cdc3f35

Please sign in to comment.