From 97d0a6887f3948115e2831d8be90aa0ff8d8ba60 Mon Sep 17 00:00:00 2001 From: VinciGit00 Date: Wed, 27 Mar 2024 21:22:04 +0100 Subject: [PATCH] add reserch web function --- scrapegraphai/utils/research_web.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scrapegraphai/utils/research_web.py diff --git a/scrapegraphai/utils/research_web.py b/scrapegraphai/utils/research_web.py new file mode 100644 index 00000000..35e71b54 --- /dev/null +++ b/scrapegraphai/utils/research_web.py @@ -0,0 +1,28 @@ +""" +Module for making the request on the web +""" +import requests + + +def search_word_on_google(word): + """ + Function that given a word it finds it on the intenet + """ + url = f"https://www.google.com/search?q={word}" + headers = { + 'User-Agent': """Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ( + KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3""" + } + + response = requests.get(url, headers=headers) + + if response.status_code == 200: + print("Search request successful!") + # You can parse the HTML response using BeautifulSoup or other libraries + print("Response content:") + print(response.text) + else: + print( + f"Failed to make search request. Status code: {response.status_code}") + +# Example usage