Interacting with Web Listeners with Python

In Python, a very popular library that can be used to interact with a web application is the requests library. While there are many well-written guides on how to use requests, including the official documentation, I will demonstrate a very basic way to get started.

As of January 2020, Python 2 will no longer be supported and is officially replaced by Python 3. However, many operating systems, including Debian, have chosen to keep the binary package python to represent Python 2 while the binary package python3 will represent Python 3. For this reason, when I use python to run a script, I’m using Python 2 and when I use python3 I’m using Python 3.

The following script will issue an HTTP request to the ManageEngine10 webserver in the labs and output the details of the relative response:

import requests
from colorama import Fore, Back, Style

requests.packages.urllib3.\
disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
def format_text(title,item):

cr = '\r\n'

section_break = cr + "*" * 20 + cr

item = str(item)

text = Style.BRIGHT + Fore.RED + title + Fore.RESET + section_break + item +
section_break

return text

r = requests.get('https://manageengine:8443/',verify=False)
print format_text('r.status_code is: ',r.status_code)
print format_text('r.headers is: ',r.headers)
print format_text('r.cookies is: ',r.cookies)
print format_text('r.text is: ',r.text),