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.

Important Note:

1. The Select operation becomes functional exclusively upon the application of a right mouse click.

2. Please make sure Chrome is installed on your machine.

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. None if unsuccessful.
  • 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. None if unsuccessful.
  • 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.
  • Maximum Data Count: The number of rows(Default value 100).
  • 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", 200, 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.38.tar.gz (82.1 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.38-py3-none-any.whl (83.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: WrapperXSelector-0.1.38.tar.gz
  • Upload date:
  • Size: 82.1 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.38.tar.gz
Algorithm Hash digest
SHA256 6b18257fd745dfab10ea9a7b02c94add89a3d5257b58e75dfab2fee9e32a8712
MD5 8ab23a5694b3dc8b9bdeb048eb87e02f
BLAKE2b-256 118c4b28dbfcb2f84bc25c3ab2ace2f76e4875d9ca7f519e5c912679590d9cea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for WrapperXSelector-0.1.38-py3-none-any.whl
Algorithm Hash digest
SHA256 8c3720d25b8dd20667416eda8fe731b6530ba7d9242e3fbd7b76372492465979
MD5 8dff81c93447c983dc05e449c4a56be2
BLAKE2b-256 127cf40aa40419f3b83bde683fdb22f2d682c2887ced419d78fc053b2f656794

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