import requests
from bs4 import BeautifulSoup
def bing_search(query):
url = "https://www.bing.com/search"
params = {
'q': query, # 查询参数
}
# 模拟浏览器请求
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, params=params, headers=headers)
# 检查响应状态
if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')
# 找到搜索结果(假设搜索结果的标题在<h2>标签内)
results = soup.find_all('h2')
# 打印搜索结果
for result in re