Skip to main content

A simple Python toolkit for web scraping

Project description

Beginner-Friendly Python Toolkit for Web Scraping

Documentation Status codecov ci-cd

A Python package for simplified web scraping functionality for data scientists new to web scraping.

Installation

$ pip install dsci524_group29_webscraping

Functions

  • fetch_html(url): Retrieves the raw HTML content from the specified URL, handling HTTP requests and potential errors.
  • parse_content(html, selector, selector_type): Parses the provided HTML content using CSS selectors or XPath to extract specified data.
  • save_data(data, format, destination): Saves the extracted data into the desired format (e.g., TXT, CSV, JSON) at the specified destination path.

Usage

Below are examples demonstrating how to use the main functions in this package:

1. Fetch HTML Content

from dsci524_group29_webscraping import fetch_html

# Fetch the raw HTML content from a webpage
url = "https://example.com"
html_content = fetch_html(url)
print(html_content)  # Outputs the HTML content of the page

2. Parse Content

from dsci524_group29_webscraping import parse_content

# Parse the HTML content to extract specific elements
selector = "h1"  # Example: extract all <h1> elements
selector_type = "css"  # Use CSS selectors
extracted_data = parse_content(html_content, selector, selector_type)
print(extracted_data)  # Outputs a list of the extracted data

3. Save Data

from dsci524_group29_webscraping import save_data

# Save the extracted data to a CSV file
data = [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]  # Example data
file_path = save_data(data, format="csv", destination="output.csv")
print(f"Data saved to: {file_path}")

This package simplifies the process of fetching, parsing, and saving web data, making it ideal for beginners.

Python Ecosystem

While libraries like BeautifulSoup and Scrapy offer comprehensive web scraping capabilities, dsci524_group29_webscraping aims to provide a more streamlined and beginner-friendly approach. By focusing on three core functions, it abstracts the complexities involved in web scraping, making it accessible for quick tasks and educational purposes.

Similar Packages:

  • webscraping: Provides web scraping functions but contains a rich set of functionality that is beyond beginner level.
  • webscraping_tools: Offers similar functionalities and many more that in our opinion, places it in the intermediate level.

dsci524_group29_webscraping differentiates itself by offering a simple set of functions that do the job for simple, beginner level needs.

Contributors

  • Lixuan Lin
  • Hui Tang
  • Sienko Ikhabi

Contributing

Interested in contributing? Check out the contributing guidelines.

Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by the specified terms.

License

Package dsci524_group29_webscraping was created by Lixuan Lin, Hui Tang and Sienko Ikhabi for the Master of Data Science, University of British Columbia. It is licensed under the terms of the MIT license.

Credits

This project was created with cookiecutter from the py-pkgs-cookiecutter template.

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

dsci524_group29_webscraping-1.1.5.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

dsci524_group29_webscraping-1.1.5-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file dsci524_group29_webscraping-1.1.5.tar.gz.

File metadata

File hashes

Hashes for dsci524_group29_webscraping-1.1.5.tar.gz
Algorithm Hash digest
SHA256 c0cdfd10dc6ca8d874926d1bc0003ff1fcad46f6c56792b1f6af75fb99abb460
MD5 c9aad5982beec75f2cfc45a900c0e39f
BLAKE2b-256 8d9cf87d08d42fc62d030a3c8d5937e898dc67547b4e36a082318a9c1fbeea2d

See more details on using hashes here.

File details

Details for the file dsci524_group29_webscraping-1.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for dsci524_group29_webscraping-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b91745467dabf2e401d8719883a1719e5f1e86fa937ccbc47f6c45bb754a1567
MD5 9dedb5225ad4367f6839f27168e3a5ca
BLAKE2b-256 2c2c1cac0675a86ee4debf64b365da590f31a0112f22a20d1bde28868f01507b

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