mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-10-27 02:45:52 +08:00
Update bing_api.py
建议改为必应搜索v7,而不是继续使用必应自定义搜索。应为必应自定义搜索在配置时会要求用户指定搜索的域,并且无法使用通配形式查询。
This commit is contained in:
@@ -10,7 +10,7 @@ class BingAPI(Search):
|
|||||||
self.module = 'Search'
|
self.module = 'Search'
|
||||||
self.source = 'BingAPISearch'
|
self.source = 'BingAPISearch'
|
||||||
self.addr = 'https://api.cognitive.microsoft.com/' \
|
self.addr = 'https://api.cognitive.microsoft.com/' \
|
||||||
'bingcustomsearch/v7.0/search'
|
'bing/v7.0/search'
|
||||||
self.id = api.bing_api_id
|
self.id = api.bing_api_id
|
||||||
self.key = api.bing_api_key
|
self.key = api.bing_api_key
|
||||||
self.limit_num = 1000 # 必应同一个搜索关键词限制搜索条数
|
self.limit_num = 1000 # 必应同一个搜索关键词限制搜索条数
|
||||||
@@ -31,8 +31,8 @@ class BingAPI(Search):
|
|||||||
self.header = {'Ocp-Apim-Subscription-Key': self.key}
|
self.header = {'Ocp-Apim-Subscription-Key': self.key}
|
||||||
self.proxy = self.get_proxy(self.source)
|
self.proxy = self.get_proxy(self.source)
|
||||||
query = 'site:' + domain + filtered_subdomain
|
query = 'site:' + domain + filtered_subdomain
|
||||||
params = {'q': query, 'customconfig': self.id, 'safesearch': 'Off',
|
params = {'q': query, 'safesearch': 'Off', 'count': self.per_page_num,
|
||||||
'count': self.per_page_num, 'offset': self.page_num}
|
'offset': self.page_num}
|
||||||
resp = self.get(self.addr, params)
|
resp = self.get(self.addr, params)
|
||||||
if not resp:
|
if not resp:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user