extract_first
Extract the first element matching a CSS selector from a webpage to retrieve specific content such as title or heading.
Instructions
Extract the first matching element from a webpage.
Useful for getting single values like page title, main heading, etc.
Args:
url: The webpage to scrape
css_selector: CSS selector for the element (e.g., "h1", "title", "meta[name='description']")
attribute: What to extract - "text" for content, or attribute name like "href", "content", "src"
javascript: Set to True for JavaScript-rendered sites
Returns:
Dictionary with the extracted value
Example:
extract_first(url="https://example.com", css_selector="title", attribute="text")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| css_selector | Yes | ||
| attribute | No | text | |
| javascript | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |