pjullrich/link-extractor
Link Extractor Chrome Extension
A Chrome extension that highlights anchor tags based on CSS selectors and extracts their URLs to a CSV file.
Features
- CSS Selector Input: Enter any CSS selector to target specific anchor tags
- Visual Highlighting: Matching links are highlighted with a pulsing yellow background and orange border
- URL Extraction: Extracts href attributes from matching anchor tags
- Relative to Absolute URL Conversion: Automatically converts relative URLs (like
/foo) to absolute URLs (likehttps://example.com/foo) - CSV Export: Saves extracted links to a CSV file with metadata
- Append Mode: Each save operation appends to the CSV file rather than overwriting
Installation
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" in the top right corner
- Click "Load unpacked" button
- Select the
data_scraper/lib/cars/extensionfolder - The extension should now appear in your extensions list and toolbar
Usage
-
Navigate to any webpage you want to extract links from
-
Click the extension icon in the Chrome toolbar to open the popup
-
Enter a CSS selector for the anchor tags you want to target. Examples:
a- All anchor tagsa.product-link- Anchor tags with class "product-link"a[href*="product"]- Anchor tags with "product" in their href.category a- Anchor tags inside elements with class "category"#main-content a- Anchor tags inside element with id "main-content"
-
Click "Highlight" to visually highlight matching links on the page
-
Click "Save CSV" to extract the URLs and save them to a CSV file
-
Click "Clear Highlights" to remove highlighting from the page
CSV Output Format
The generated CSV includes the following columns:
- URL: The absolute URL (converted from relative if needed)
- Original Href: The original href attribute value
- Link Text: The visible text content of the link
- Link Title: The title attribute of the link (if present)
- Domain: The domain of the webpage where links were extracted
- CSS Selector: The CSS selector that was used
- Extracted At: Timestamp of when the extraction was performed
File Location
CSV files are saved to your default download location with the filename format:
extracted-links-YYYY-MM-DD-HH-MM.csv
Technical Details
- Manifest Version: 3
- Permissions:
activeTab,storage,downloads - Host Permissions:
<all_urls>(required for content script injection)
Troubleshooting
- No links highlighted: Check that your CSS selector is correct and matches anchor tags on the page
- CSV not downloading: Ensure Chrome has permission to download files
- Extension not working: Try refreshing the page after installing the extension
- Relative URLs not converting: The extension uses the current page's domain as the base for conversion
Example Selectors
a[class*="product"]- Links with "product" in their class namea[href^="/category/"]- Links starting with "/category/".menu a, .sidebar a- Links in menu or sidebar sectionsa:not([href^="mailto:"])- All links except email linkstable tr td a- Links inside table cells