56 lines
1.2 KiB
Python
Executable file
56 lines
1.2 KiB
Python
Executable file
#!/bin/env python
|
|
|
|
from argparse import ArgumentParser
|
|
from logging import info, debug, error, basicConfig, DEBUG
|
|
from requests import get, HTTPError
|
|
|
|
# import bs4
|
|
|
|
ROOT_URL = "https://cpularp.mylarp.dev/"
|
|
|
|
|
|
def build_arguent_parser() -> ArgumentParser:
|
|
"""A function to build the argument parser.
|
|
|
|
Returns:
|
|
ArgumentParser: The initialized argument parser object.
|
|
"""
|
|
|
|
parser = ArgumentParser(
|
|
prog="mylarp-api", description="A python API for mylarp", epilog=""
|
|
)
|
|
parser.add_argument(
|
|
"-u",
|
|
"--uri",
|
|
help="The uri of the mylarp page to parse.",
|
|
)
|
|
parser.add_argument(
|
|
"-v",
|
|
"--verbose",
|
|
help="Output debug information.",
|
|
action="store_true",
|
|
)
|
|
return parser
|
|
|
|
|
|
def parse_mylarp_page(uri: str):
|
|
info(f"Attempting to parse from {uri}")
|
|
try:
|
|
response = get(f"{ROOT_URL}{uri}")
|
|
except HTTPError as e:
|
|
error(f"Error attempting to request from uri: {e}")
|
|
debug(response.text)
|
|
return
|
|
|
|
|
|
def main():
|
|
return
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = build_arguent_parser()
|
|
args = parser.parse_args()
|
|
if args.verbose:
|
|
basicConfig(level=DEBUG)
|
|
parse_mylarp_page(args.uri)
|
|
main()
|