tap
Back

bing/search

bingRead-only

Bing 搜索

www.bing.com
Last 7 days
0
Last 30 days
0
All time
0
bing/search.js
/* @meta
{
  "name": "bing/search",
  "description": "Bing 搜索",
  "domain": "www.bing.com",
  "args": {
    "query": {"required": true, "description": "Search query"},
    "count": {"required": false, "description": "Number of results (default 10)"}
  },
  "readOnly": true,
  "example": "tap site bing/search \"Claude Code\""
}
*/

async function(args) {
  const query = args.query;
  if (!query) return {error: 'query is required'};
  const count = args.count || 10;

  const url = 'https://www.bing.com/search?q=' + encodeURIComponent(query) + '&count=' + count;
  const resp = await fetch(url, {credentials: 'include'});
  if (!resp.ok) return {error: 'HTTP ' + resp.status};

  const html = await resp.text();
  const parser = new DOMParser();
  const doc = parser.parseFromString(html, 'text/html');

  const items = doc.querySelectorAll('li.b_algo');
  const results = [];
  items.forEach(li => {
    const anchor = li.querySelector('h2 > a');
    if (!anchor) return;
    const title = anchor.textContent.trim();
    const href = anchor.getAttribute('href') || '';
    const snippet = (li.querySelector('p') || {}).textContent || '';
    results.push({title, url: href, snippet: snippet.trim()});
  });

  return {query, count: results.length, results};
}
Updated Mar 31, 2026Created Mar 31, 2026SHA-256: 8ee77fc47c8f