Skip to main content

fetchx library and its two main functions "call" and "fetch" are designed to allow users to rapidly scrape/automate web applications.

Project description

uurest

Library that allows developers to easily integrate their application(s) with Unicorn Systems solutions and products using REST API.

!!!!! DEPRECATED. DO NOT USE THIS LIBRARY !!!!!

Usage

How To Use the Library

from uurest import *

# fetch function behavior can be setup globally or by every "fetch" call
fetch_global_setup(raise_exception_on_error=False, timeout=120, verbose=True)

response = fetch("https://www.websitewhichdoesnotexist.net") # fetch non existing web page
# response.json = {"__error__": "Unknown response type received when calling \"https://www.websitewhichdoesnotexist.net\" ...
response = fetch("http://devserver.com/tsMetadataTransfer/get") # fetch data without authorization / without sending a token
# response.json = {"__error__": "Http/Https error code \"403\" occured. Cannot process text data ...
response = fetch("https://upload.wikimedia.org/wikipedia/commons/c/cd/Google_Logo_%281998%29.png") # fetch binary file
# response.json = {"__base64__": "iVBORw0KGgoAAAANSUhEUgAAC0AAAAMWEAYAAAAy59uuAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQ ...
response = fetch("https://upload.wikimedia.org/wikipedia/commons/2/2f/Google_2015_logo.svg") # fetch svg, html, css, js,  ...
# response.json = {"__text__": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3  ...

# open web browser (Chrome, Edge). On the keyboard press F12 to open "DevTools". Click on the "Network" tab in the menu
# Select the request in the list. Right click on the selected item. In the popup menu click on the "Copy" -> "Copy as fetch"
# Paste the copied command from the clipboard directly into the source code. It should look like the code below.
response = fetch("https://jsonplaceholder.typicode.com/todos/1", {
    "headers": {
        "accept": "*/*",
    },
    "referrer": "https://jsonplaceholder.typicode.com/",
    "body": null,
    "method": "GET"
})
# response.json = {"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}

You can play with the response using following inbuild methods

from uurest import *

response = fetch("https://jsonplaceholder.typicode.com/todos/1", {
    "headers": {
        "accept": "*/*",
    },
    "referrer": "https://jsonplaceholder.typicode.com/",
    "body": null,
    "method": "GET"
})
# prints formatted json
print(response) # {"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}
print(response.json["title"])  # delectus aut autem
json_object = response.json.parse() # transforms dictionary into the object
if json_object.completed:
    print("Successfully competed")
else:
    print("Not completed")
print(str(response.http_status_code))
print(response.content_type)
response.save_json("./test.json")
response.save_raw_content("./raw_content.raw")

Check out: https://www.youtube.com/

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

fetchx-0.0.39.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

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

fetchx-0.0.39-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file fetchx-0.0.39.tar.gz.

File metadata

  • Download URL: fetchx-0.0.39.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.1

File hashes

Hashes for fetchx-0.0.39.tar.gz
Algorithm Hash digest
SHA256 6a7b773e19668936fa5b6f81ae3faa8b2de85c4a0473dde6c2190a54a604f078
MD5 0caac7d9758bcbdf099664e767194f58
BLAKE2b-256 194782f2fa89380675978e55f3eb0edb3511cae4f206d5193c00fbf14c448c1a

See more details on using hashes here.

File details

Details for the file fetchx-0.0.39-py3-none-any.whl.

File metadata

  • Download URL: fetchx-0.0.39-py3-none-any.whl
  • Upload date:
  • Size: 44.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.1

File hashes

Hashes for fetchx-0.0.39-py3-none-any.whl
Algorithm Hash digest
SHA256 0dbee57263e3ebf0535369ae74c64f9f84a7c6dc692ff99e43b6e64d2952a198
MD5 2aaa257e52cdd31538fb8782be7b32bc
BLAKE2b-256 0c0a556109e9be44ec5f4059ee6f771c101d88abc66c70672255b8a7bf3ed81a

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