Skip to main content

CraftAPI, easy to use scraping and API library.

Project description

CraftAPI

CraftAPI is a simple-to-use Python library providing a set of tools for interacting with websites and retrieving various types of information, as well as utility functions for variable manipulation and time formatting.

Installation

Install the package using pip:

pip install craftllc-api

Usage

ReqTools Class

This class provides methods for web scraping and making HTTP requests.

from craftapi import ReqTools, UnknownMethod

req_tools = ReqTools()

# Get page title
title = req_tools.get_page_title("https://www.python.org/")
print(f"Page Title: {title}")

# Get all links on a page
links = req_tools.get_all_links("https://www.python.org/")
print("All Links:")
for link in links[:5]: # Print first 5 links
    print(link)

# Check HTTP status code
status_code = req_tools.check_http_status("https://www.python.org/")
print(f"HTTP Status Code: {status_code}")

# Extract all paragraphs
paragraphs = req_tools.extract_paragraphs("https://www.python.org/")
print("First Paragraph:")
if paragraphs:
    print(paragraphs[0])

# Get meta tags
meta_tags = req_tools.get_meta_tags("https://www.python.org/")
print("Meta Tags:")
for name, content in meta_tags.items():
    print(f"  {name}: {content}")

# Check SSL certificate (basic check)
ssl_status = req_tools.check_ssl_certificate("https://www.google.com/")
print(f"SSL Status: {ssl_status}")

# Save HTML content to a file
save_status = req_tools.save_html_to_file("https://www.python.org/", "python_org.html")
print(save_status)

# Extract list items
list_items = req_tools.extract_list_items("https://www.python.org/")
print("First List Item:")
if list_items:
    print(list_items[0])

# Get the first H1 tag
h1_tag = req_tools.get_first_h1("https://www.python.org/")
print(f"First H1 Tag: {h1_tag}")

# Get all script URLs
scripts = req_tools.get_all_scripts("https://www.python.org/")
print("First Script URL:")
if scripts:
    print(scripts[0])

# Extract form data
form_data = req_tools.extract_form_data("https://www.w3schools.com/html/html_forms.asp")
print("Form Data (first form):")
if form_data:
    print(form_data[0])

# Get CSS links
css_links = req_tools.get_css_links("https://www.python.org/")
print("First CSS Link:")
if css_links:
    print(css_links[0])

# Find all image URLs
image_urls = req_tools.find_all_images_url("https://www.python.org/")
print("First Image URL:")
if image_urls:
    print(image_urls[0])

# WHOIS lookup
whois_info = req_tools.whois("8.8.8.8")
print("WHOIS Info for 8.8.8.8:")
for key, value in whois_info.items():
    print(f"  {key}: {value}")

# Example of UnknownMethod exception
try:
    req_tools.find_all_images_url("https://example.com", method="INVALID")
except UnknownMethod as e:
    print(f"Caught expected exception: {e}")

Wordle Class

This class provides methods related to New York Times games, specifically Wordle.

from craftapi import Wordle

wordle_game = Wordle()

# Get today's Wordle answer
wordle_answer = wordle_game.answer
print(f"Today's Wordle Answer: {wordle_answer}")

VarTools Class

This class provides utility methods for variable inspection and time formatting.

from craftapi import VarTools

my_vars = {"name": "CraftAPI", "version": 0.1, "is_active": True}
var_tools = VarTools(my_vars)

# Get variable value
name_value = var_tools.get_var_value("name")
print(f"Value of 'name': {name_value}")

# Clean variable type
name_type = var_tools.clean_type("name")
version_type = var_tools.clean_type("version")
print(f"Type of 'name': {name_type}")
print(f"Type of 'version': {version_type}")

# Format time in seconds
formatted_time_seconds = var_tools.format_time(30)
formatted_time_minutes = var_tools.format_time(150)
formatted_time_hours = var_tools.format_time(7200)
formatted_time_days = var_tools.format_time(90000)
print(f"30 seconds: {formatted_time_seconds}")
print(f"150 seconds: {formatted_time_minutes}")
print(f"7200 seconds: {formatted_time_hours}")
print(f"90000 seconds: {formatted_time_days}")

License

This project is licensed under the MIT License.

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

craftllc_api-0.1.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

craftllc_api-0.1.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file craftllc_api-0.1.3.tar.gz.

File metadata

  • Download URL: craftllc_api-0.1.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for craftllc_api-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f120c9b49bcf26c0a85e5218098d7d6b1c062eaa91bedb4603bd62b89a665298
MD5 04933dbf0a068ef2003c3c2192494d8f
BLAKE2b-256 8580c6053fde2e11a0b296850a9b7894909d47e6566250991e28f1e59274e57a

See more details on using hashes here.

File details

Details for the file craftllc_api-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: craftllc_api-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for craftllc_api-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 794f18db3f3b4b16fb992e09c64b9d2c843e0cf9e113260670dd019cc9c53193
MD5 0f8bc41c09a63296869874754ee0aa6c
BLAKE2b-256 dfb85d8ec816db0982cca4fab0675a01694ae4ce9da76a6c76bdb460a3ed3099

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