what port does python requests use

What Port Does Python Requests Use?

Python Requests is a popular library that allows us to send HTTP requests easily in Python. When we use Python Requests to send a request, it uses the default HTTP port which is port 80 for HTTP and port 443 for HTTPS. These ports are used by default if we don't specify any specific port in our code.

For example, if we want to send a GET request to a URL using Python Requests, we can do it like this:


    import requests

    response = requests.get("https://www.example.com")
  

In this example, Python Requests will use port 443 because we are using the HTTPS protocol.

If we want to use a different port, we can specify it in the URL. For example, if we want to use port 8080, we can do it like this:


    import requests

    response = requests.get("http://www.example.com:8080")
  

In this example, Python Requests will use port 8080 instead of the default port of 80 for HTTP.