Skip to main content

The WrapperXSelector[Crow] is a Python-based tool that streamlines web scraping and data extraction tasks through the creation and utilization of wrappers.

Project description

WrapperXSelector(CroW)

PyPI Version Python Versions License

The WrapperXSelector(CroW) is a Python-based tool that streamlines web scraping and data extraction tasks through the creation and utilization of wrappers. Leveraging Selenium for web automation and BeautifulSoup for HTML parsing, the project empowers users to effortlessly set up wrappers for tables and general data on web pages. With functions like setTableWrapper and setGeneralWrapper, users can define the structure of data extraction, while getWrapperData facilitates the retrieval of data based on these wrappers. Additionally, the project offers functionality for listing existing wrappers with listWrappers. Overall, the Web Wrapper Project serves as a versatile solution for simplifying web scraping workflows and enhancing data extraction efficiency in Python.

Table of Contents

Installation

Requirements

  • Python 3.x
  • Chrome browser (for Selenium)

Installation Steps

You can install the Web Wrapper Project using pip:

pip install WrapperXSelector

Usage

Setting up a Table Wrapper

To set up a table wrapper, use the setTableWrapper function. This function automates the process of creating a web scraping wrapper for a table on a specified web page.

Function Input:

  • URL (string): The URL of the web page containing the table you want to scrape.
  • Wrapper Name (string, optional): A custom name for the wrapper. If not provided, a unique name will be generated.
from web_wrapper_project import setTableWrapper

# Example: Setting up a table wrapper for "https://example.com" with a custom name
result = setTableWrapper("https://example.com", wrapper_name="my_table_wrapper")
print(result)

Function Output:

The setTableWrapper function returns a tuple with information about the operation:

  • Success Flag (bool): True if the operation was successful, False otherwise.
  • Wrapper Name (string): The name assigned to the wrapper, either custom or auto-generated.
  • Error Code (int or None): If unsuccessful, an error code indicating the nature of the failure. None if successful.
  • Error Type (string or None): The type of the raised exception (if any). None if successful.
  • Error Message (string or None): A descriptive error message (if any). None if successful.
# Example Output
# (True, 'my_table_wrapper_abc123.json', None, None, None)

Setting up a General Wrapper

To set up a general wrapper, use the setGeneralWrapper function. This function facilitates the creation of a web scraping wrapper for a general web page structure.

Function Input:

  • URL (string): The URL of the web page you want to scrape.
  • Wrapper Name (string, optional): A custom name for the wrapper. If not provided, a unique name will be generated.
  • Repeat (string, optional): Indicate whether to repeat the pattern. Options are 'yes' or 'no'. Default is 'no'.
from web_wrapper_project import setGeneralWrapper

# Example: Setting up a general wrapper for "https://example.com" with a custom name and repeat pattern
result = setGeneralWrapper("https://example.com", wrapper_name="my_general_wrapper", repeat="yes")
print(result)

Function Output:

The setGeneralWrapper function returns a tuple with information about the operation:

  • Success Flag (bool): True if the operation was successful, False otherwise.
  • Wrapper Name (string): The name assigned to the wrapper, either custom or auto-generated.
  • Error Code (int or None): If unsuccessful, an error code indicating the nature of the failure. None if successful.
  • Error Type (string or None): The type of the raised exception (if any). None if successful.
  • Error Message (string or None): A descriptive error message (if any). None if successful.
# Example Output
# (True, 'my_table_wrapper_abc123.json', None, None, None)

Getting Wrapper Data

To retrieve data from a previously set up wrapper, use the getWrapperData function. This function allows you to extract structured data from a web page based on the defined wrapper.

Function Input:

  • Wrapper Name (string): The name of the wrapper from which to retrieve data.
  • URL (string, optional): The URL of the web page. If not provided, the URL from the original wrapper setup will be used.
from web_wrapper_project import getWrapperData

# Example: Getting data from the wrapper named "my_table_wrapper"
result = getWrapperData("my_table_wrapper", url="https://example.com")
print(result)

Function Output:

The getWrapperData function returns a tuple with information about the operation:

  • Success Flag (bool): True if the operation was successful, False otherwise.
  • Data (list or string): If successful, the structured data extracted from the web page based on the wrapper. If unsuccessful, an error message describing the issue.
# Example Output
# (True, [['Column 1', 'Column 2'], ['Data 1', 'Data 2']])

# Example Output for Error
# (False, 'Permission denied: Unable to write to wrappers_5ece4797eaf5e')

Listing Wrappers

To retrieve a list of all available wrappers, use the listWrappers function. This function provides the names of all wrappers that have been set up in the system.

Function Input:

None

from web_wrapper_project import listWrappers

# Example: Listing all available wrappers
result = listWrappers()
print(result)

Function Output:

The listWrappers function returns a tuple with information about the operation:

  • Success Flag (bool): True if the operation was successful, False otherwise.
  • Wrappers (list or string): If successful, a list containing the names of all available wrappers. If unsuccessful, an error message describing the issue.
# Example Output
# (True, ['wrapper1.json', 'wrapper2.json'])

# Example Output for Error
# (False, 'Permission denied: Unable to read the wrappers')

Dependencies

Disclaimer

Intended for educational and legal use only. Users must comply with the terms of service of scraped websites and applicable laws and regulations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

WrapperXSelector-0.1.31.tar.gz (81.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

WrapperXSelector-0.1.31-py3-none-any.whl (83.0 kB view details)

Uploaded Python 3

File details

Details for the file WrapperXSelector-0.1.31.tar.gz.

File metadata

  • Download URL: WrapperXSelector-0.1.31.tar.gz
  • Upload date:
  • Size: 81.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.1

File hashes

Hashes for WrapperXSelector-0.1.31.tar.gz
Algorithm Hash digest
SHA256 07e29661aa44e979a3aa7b73e36fd895d62047348e3e9dc562f721ee598f3d89
MD5 08681e44328fb9ac2a1bd3691419edfc
BLAKE2b-256 6970feb2d1165b620608dde1d39952238845544680a27059a1f86be7ac81d5cc

See more details on using hashes here.

File details

Details for the file WrapperXSelector-0.1.31-py3-none-any.whl.

File metadata

File hashes

Hashes for WrapperXSelector-0.1.31-py3-none-any.whl
Algorithm Hash digest
SHA256 b5c95c217aa6b1ff9a1da9e07cc3468a58671f32c14183c4c517da47828c798f
MD5 ad79124af9c6c3da32a237a9530c60ca
BLAKE2b-256 62740733435dfe907721b7487d6b4b693a2aac5612b6911d9b0ddf21e1123303

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page