申请免费的必应搜索API

申请免费的必应搜索API



前言

准备条件:
1、outlook邮箱
2、招商银行全币种VISA信用卡【建议之前就有一张招商银行信用卡,那么VISA相对比较好申请】


一、原理

1.1 登录

https://www.customsearch.ai/
使用outlook邮箱登录 sign in
在这里插入图片描述

1.2 进入

在这里插入图片描述
创建一个new instance
配置需要访问的URL
在这里插入图片描述
这里输入 https://cn.bing.com/

1.3 获取密钥

在这里插入图片描述

1.4 申请VISA信用卡

填写信用卡的相关信息,实测招商银行的全币种VISA可以通过

1.5 创建必应自定义搜索资源

在这里插入图片描述
这里的资源组、名称自定义填写;定价层看实际需求填写,最后审阅并创建


二、创建成功

在这里插入图片描述
本页有测试,市场是选择不同的地域,中国是zh-CN, 香港省是zh-HK
在这里插入图片描述

在这里插入图片描述

以下是python的示例代码


#Copyright (c) Microsoft Corporation. All rights reserved.
#Licensed under the MIT License.

# -*- coding: utf-8 -*-

import json
import os 
from pprint import pprint
import requests

'''
This sample makes a call to the Bing Web Search API with a query and returns relevant web search.
Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-web-search/overview
'''

# Add your Bing Search V7 subscription key and endpoint to your environment variables.
subscription_key = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
endpoint = os.environ['BING_SEARCH_V7_ENDPOINT'] + "/bing/v7.0/search"

# Query term(s) to search for. 
query = "Microsoft"

# Construct a request
mkt = 'en-US'
params = { 'q': query, 'mkt': mkt }
headers = { 'Ocp-Apim-Subscription-Key': subscription_key }

# Call the API
try:
    response = requests.get(endpoint, headers=headers, params=params)
    response.raise_for_status()

    print("
Headers:
")
    print(response.headers)

    print("
JSON Response:
")
    pprint(response.json())
except Exception as ex:
    raise ex
    
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值