| import requests |
| from bs4 import BeautifulSoup |
| import gradio as gr |
|
|
| def search_google_videos(query): |
| |
| url = f'https://www.google.com/search?q={query}&tbm=vid' |
|
|
| |
| headers = { |
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' |
| } |
| response = requests.get(url, headers=headers) |
|
|
| |
| soup = BeautifulSoup(response.text, 'html.parser') |
|
|
| |
| results = [] |
| for result in soup.find_all('div', class_='BVG0Nb'): |
| title = result.find('h3').text |
| link = result.find('a')['href'] |
| results.append(f"Title: {title}\nLink: {link}") |
| |
| return "\n\n".join(results) |
|
|
| |
| iface = gr.Interface( |
| fn=search_google_videos, |
| inputs="text", |
| outputs="text", |
| title="Google Video Search", |
| description="Enter a query to search videos on Google." |
| ) |
|
|
| |
| iface.launch() |
|
|