use Bing search
This commit is contained in:
22
openAI_validate_data/2025-07_gpt02_use-bing/request.py
Normal file
22
openAI_validate_data/2025-07_gpt02_use-bing/request.py
Normal 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')
|
Reference in New Issue
Block a user