Often, you may want to access a website’s internal API or pull an authorization token from a page. This can be done with Simplex’s network handling functions.

Network Request Overview

If you navigate to a legacy web portal, open the Network tab in Chrome Developer Tools, then reload the page, you might see something like this:

Network requests and responses on a legacy web portal. Click to expand.

The network requests are highlighted in red, and the response (omitted for privacy) is highlighted in green.

This is the website’s internal API, and it contains information that can be useful.

We’ve seen customers use websites’ internal APIs to pull information that they then

Network Request Functions

To pull the response from a network request, you can use the get_network_response function with the request’s URL.

You can find the URL of the network request by clicking on the network request in the Network tab of Chrome Developer Tools and viewing the Headers panel.

Network request URL in Chrome Developer Tools. Click to expand.

Example Usage

Python
from simplex import Simplex

simplex = Simplex(api_key="your_api_key")

 # No need for proxies in this example -- Simplex doesn't block our automation.
session_id, livestream_url = simplex.create_session(proxies=False)
simplex.goto("https://simplex.sh/network-request-example.html")

# You can use a partial URL in get_network_response if it uniquely identifies the request.
# "https://www.simplex.sh/response.json" is the full URL, but "https://www.simplex.sh/response" works as well.
request_url = "https://www.simplex.sh/response"
network_response = simplex.get_network_response(request_url)
print(network_response)

simplex.close_session()