🌐 Web Module

The Web module provides simple tools for interacting with websites and web services. You can send HTTP requests, download files, parse HTML documents, extract links, work with JSON files, handle URLs, and create reusable HTTP sessions.

Features
  • HTTP GET Requests
  • HTTP POST Requests
  • Download Files
  • Parse HTML
  • Extract Page Titles
  • Extract Hyperlinks
  • Load JSON
  • Save JSON
  • Parse URLs
  • Join URLs
  • Create HTTP Sessions
  • Validate URLs
  • Response Text
  • Response JSON

🚀 Quick Example

Fetch a web page using a GET request.

💻 Code

import allkitpy

response = allkitpy.web.get(
    "https://example.com"
)

print(
    response.status_code
)

📤 Output

200

📚 Functions


📥 get()

Send an HTTP GET request.

💻 Code

import allkitpy

response = allkitpy.web.get(
    "https://httpbin.org/get"
)

print(
    response.status_code
)

📤 Output

200

📤 post()

Send an HTTP POST request.

💻 Code

import allkitpy

response = allkitpy.web.post(
    "https://httpbin.org/post",
    json={
        "name":"Alice"
    }
)

print(
    response.status_code
)

📤 Output

200

⬇️ download()

Download a file from a URL.

💻 Code

import allkitpy

allkitpy.web.download(
    "https://example.com/logo.png",
    "logo.png"
)

📤 Output

logo.png

📄 html()

Parse an HTML document using BeautifulSoup.

💻 Code

import allkitpy

html = "<h1>Hello</h1>"

soup = allkitpy.web.html(
    html
)

print(
    soup.h1.text
)

📤 Output

Hello

🏷️ title()

Extract the page title from HTML.

💻 Code

import allkitpy

html = """



My Site



"""

print(
    allkitpy.web.title(
        html
    )
)

📤 Output

My Site

Extract every hyperlink from an HTML document.

💻 Code

import allkitpy

html = """

Home



About

"""

print(
    allkitpy.web.links(
        html
    )
)

📤 Output

[
'home.html',
'about.html'
]

📂 load()

Load a JSON file into a Python object.

💻 Code

import allkitpy

data = allkitpy.web.load(
    "config.json"
)

print(data)

📤 Output

{
    "theme":"dark",
    "font":18
}

💾 save()

Save a Python dictionary or list as a JSON file.

💻 Code

import allkitpy

settings = {

    "theme":"dark",

    "language":"en"

}

allkitpy.web.save(
    settings,
    "settings.json"
)

📤 Output

settings.json

🌐 parse()

Parse a URL into its individual components.

💻 Code

import allkitpy

url = allkitpy.web.parse(

    "https://example.com/docs/index.html"

)

print(url.scheme)

print(url.netloc)

print(url.path)

📤 Output

https

example.com

/docs/index.html

🔗 join()

Combine a base URL with another path.

💻 Code

import allkitpy

url = allkitpy.web.join(

    "https://example.com/",

    "about"

)

print(url)

📤 Output

https://example.com/about

🌍 create()

Create a reusable HTTP session.

💻 Code

import allkitpy

session = allkitpy.web.create()

response = session.get(

    "https://httpbin.org/get"

)

print(
    response.status_code
)

📤 Output

200

✅ validate_url()

Validate whether a URL is correctly formed.

💻 Code

import allkitpy

allkitpy.web.validate_url(

    "https://example.com"

)

📤 Output

Valid URL

📄 response_text()

Return the text content of an HTTP response. This is useful for reading HTML pages, plain text, or other text-based web responses.

💻 Code

import allkitpy

response = allkitpy.web.get(

    "https://example.com"

)

text = allkitpy.web.response_text(
    response
)

print(text[:120])

📤 Output

<!DOCTYPE html>
<html>
<head>
<title>
Example Domain
</title>
...

📦 response_json()

Convert an HTTP response into a Python dictionary or list by parsing its JSON content.

💻 Code

import allkitpy

response = allkitpy.web.get(

    "https://httpbin.org/json"

)

data = allkitpy.web.response_json(
    response
)

print(data)

📤 Output

{
    "slideshow": {
        ...
    }
}

📘 Module Summary

The Web module simplifies common internet-related tasks into an easy-to-use API. Whether you're sending HTTP requests, downloading files, parsing HTML documents, handling JSON, or manipulating URLs, the module provides a clean and beginner-friendly interface while still being powerful enough for automation projects.

Included Categories
  • 🌍 HTTP Requests
  • ⬇️ File Downloads
  • 📄 HTML Parsing
  • 🔗 Link Extraction
  • 📦 JSON Utilities
  • 🌐 URL Utilities
  • 🤝 HTTP Sessions
  • ✅ URL Validation
  • 📝 Response Helpers

🚀 Typical Workflow

💻 Example

import allkitpy

response = allkitpy.web.get(

    "https://example.com"

)

html = allkitpy.web.response_text(
    response
)

title = allkitpy.web.title(
    html
)

links = allkitpy.web.links(
    html
)

print(title)

print(links)

📤 Output

Example Domain

[
    "https://www.iana.org/..."
]