web crawler that searches keyword once a day on google in python

main.py
import requests
from bs4 import BeautifulSoup
import schedule
import time

def search_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.")

def job():
    search_google("your_keyword_here")

# Schedule the job to run once a day
schedule.every().day.at("09:00").do(job)

while True:
    schedule.run_pending()
    time.sleep(1)
752 chars
31 lines

gistlibby LogSnag