web crawler that searches keyword once a day on google in python
main.py
import requests
from bs4 import BeautifulSoup
import schedule
import time
defsearch_google(keyword): url = "https://www.google.com/search?q=" + keyword
headers = {
"User-Agent": "Mozilla/5.0" }
response = requests.get(url, headers=headers)
if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')
search_results = soup.find_all('div', class_='BVG0Nb')
for result in search_results:
print(result.text)
else:
print("Failed to get search results.")
defjob(): search_google("your_keyword_here")
# Schedule the job to run once a dayschedule.every().day.at("09:00").do(job)
whileTrue:
schedule.run_pending()
time.sleep(1)