Files
data-processing/openAI_validate_data/2025-07_gpt02_use-bing/request.py
Daniel Abbassi 06b2141cb3 use Bing search
2025-07-16 15:31:33 +02:00

23 lines
521 B
Python

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')