Skip to content

HFerrahoglu/xpath-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XPath Extractor

License: MIT

A powerful Chrome extension for extracting text and attributes from web page elements using XPath expressions. Perfect for developers, data analysts, and web scrapers.

Features

  • Right-click Extraction: Right-click any element on a webpage to automatically generate its XPath and extract associated text.
  • Manual XPath Testing: Input custom XPath expressions and test them directly in the popup.
  • Dual Mode Extraction: Choose between extracting text content or element attributes (returned as JSON).
  • Element Highlighting: Visually highlight matching elements on the page for easy identification.
  • Wildcard Support: Use [*] in XPath to extract from multiple similar elements automatically.
  • Export Options: Export results as plain text, JSON array, CSV, or full JSON with metadata.
  • Copy Functionality: Quickly copy XPath, text, or arrays to clipboard.
  • Dark Mode: Toggle between light and dark themes for comfortable use.
  • Integrated Settings: Customize default export format and more.
  • Privacy-Focused: All operations are local; no data is sent externally.

Installation

Manual Installation (Development)

  1. Download or clone this repository.
  2. Open Chrome and navigate to chrome://extensions/.
  3. Enable "Developer mode" in the top right.
  4. Click "Load unpacked" and select the Xpath directory.
  5. The extension should now be installed and visible in your toolbar.

Usage

Extracting via Context Menu

  1. Right-click on any element on a webpage.
  2. Select "Get XPath and Extract Texts" from the context menu.
  3. The popup will open with the generated XPath and extracted texts.

Manual XPath Input

  1. Click the extension icon in the toolbar to open the popup.
  2. Enter an XPath expression in the textarea (e.g., //div[@class='content']).
  3. Select extraction mode: Text or Attributes.
  4. Click "Test" to evaluate the XPath and display results.
  5. Use "Highlight" to visually mark elements on the page.
  6. Copy data or export to CSV/JSON as needed.

Wildcard Usage

  • Use [*] in your XPath to match any index, e.g., //ul/li[*]/a.
  • The extension will attempt up to 50 variations to find matching elements.

Permissions

The extension requires the following permissions:

  • contextMenus: For adding the right-click menu option.
  • activeTab: To interact with the current tab.
  • scripting: To run scripts on web pages.
  • storage: To temporarily store XPath data between popup opens.
  • Host permissions for all URLs to work on any website.

Privacy Policy

Read our Privacy Policy for details on data handling.

Development

Prerequisites

  • Chrome browser

Building

  1. Clone the repository: git clone https://github.com/HFerrahoglu/XPath-Extractor.git
  2. Load unpacked in Chrome as described above.

File Structure

  • manifest.json: Extension configuration.
  • background.js: Service worker for context menus.
  • content.js: Injected script for XPath processing.
  • popup.html/js/css: Popup UI and logic.
  • icons/: Extension icons.
  • privacy.html: Privacy policy page.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature-name.
  3. Commit changes: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature-name.
  5. Open a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you find this extension helpful, consider buying me a coffee ☕.

For issues or questions, open an issue on GitHub or contact [hamzacferrahoglu@gmail.com].

Changelog

v1.0.1

  • Added attribute extraction mode.
  • Improved UI with dark mode and collapsible settings.
  • Enhanced error handling and performance.

About

A powerful Chrome extension for extracting text and attributes from web page elements using XPath expressions. Perfect for developers, data analysts, and web scrapers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors