Skip to main content
Glama

scraping_browser_links

Extract all hyperlinks, text content, and CSS selectors from a webpage to validate click targets and gather navigation data for web scraping and browser automation.

Instructions

Get all links on the current page, text and selectors It's strongly recommended that you call the links tool to check that your click target is valid

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that executes the scraping_browser_links tool. It retrieves the current browser page and uses $$eval to extract text, href, and outerHTML for all anchor elements, returning them as formatted JSON.
    execute: async()=>{ const page = await (await require_browser()).get_page(); try { const links = await page.$$eval('a', elements=>{ return elements.map(el=>{ return { text: el.innerText, href: el.href, selector: el.outerHTML, }; }); }); return JSON.stringify(links, null, 2); } catch(e){ throw new UserError(`Error getting links: ${e}`); } },
  • Zod schema for the tool parameters (no input parameters required).
    parameters: z.object({}),
  • Registration of the scraping_browser_links tool in the exported tools array (included at line 311).
    export const tools = process.env.API_TOKEN ? [ scraping_browser_navigate, scraping_browser_go_back, scraping_browser_go_forward, scraping_browser_links, scraping_browser_click, scraping_browser_type, scraping_browser_wait_for, scraping_browser_screenshot, scraping_browser_get_text, scraping_browser_get_html, scraping_browser_scroll, scraping_browser_scroll_to, ] : [scraping_browser_activation_instructions];
  • Tool metadata including name and description.
    name: 'scraping_browser_links', description: [ 'Get all links on the current page, text and selectors', "It's strongly recommended that you call the links tool to check that " +'your click target is valid', ].join('\n'),
  • Helper function to get or initialize the browser session, used by the tool handler.
    const require_browser = async()=>{ if (!open_session) { open_session = new Browser_session({ cdp_endpoint: await calculate_cdp_endpoint(), }); } return open_session; };

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dsouza-anush/brightdata-mcp-heroku'

If you have feedback or need assistance with the MCP directory API, please join our Discord server