必应搜索v7.0
官方文档是php5.6x,调整代码
函数getbing($url,$key) {
$ ch = curl _ init();
$ user _ agent = " Mozilla/5.0(Windows NT 5.1)apple WebKit/537.36(KHTML,喜欢Gecko)Chrome/33 . 0 . 1750 . 146 Safari/537.36 ";
curl_setopt($ch,CURLOPT_URL,$ URL);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Ocp-Apim-Subion-Key:')。$key。''));
curl_setopt($ch,CURLOPT_TIMEOUT,8);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_NOSIGNAL,true);
curl_setopt($ch,CURLOPT_USERAGENT,$ USER _ AGENT);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
$ data = curl _ exec($ ch);
curl _ close($ ch);
返回$ data
}
用法:
$ bing = getTokens(' https://API . cognitive . Microsoft . com/bing/v 7.0/search?Q = '。urlcode(关键字)。&:count = 10 & amp;offset= '。$ p . 0 & amp。mkt = zh-tw & amp;Safesearch =适中',$ key = " web search key ");
$p是分页偏移量!
参考:https://docs . Microsoft . com/en-us/azure/cognitive-services/bing-web-search/quick starts/PHP
https://docs . Microsoft . com/en-us/rest/API/cognitive services/bing-web-API-V7-reference # market-codes
http://www.zendei.com/article/14132.html
1.《必应搜索 必应 Web 搜索 API v7.0》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。
2.《必应搜索 必应 Web 搜索 API v7.0》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。
3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/shehui/1488523.html