use Bing search

This commit is contained in:
Daniel Abbassi
2025-07-16 15:31:33 +02:00
parent 92c27a39cb
commit 06b2141cb3
10 changed files with 114 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
from openai import OpenAI
from copy import deepcopy
import requests, sys, os
from bs4 import BeautifulSoup
choice = 'start'
query = 'python chatgpt -stackoverflow'
url = f'https://www.bing.com/search?q={query.replace(" ", "+")}'
headers = {'User-Agent': 'Mozilla/5.0'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
links = soup.select('li.b_algo h2 a')
print('Response:')
for link in links:
print('>', link.text, '< links to ', link['href'])
print('Ok ciao')