Please make this Python code better

Job ID: 35808946

Budget: €30 – €250 EUR

The code shows me my IP from line 6. I want to modify the code so that the code connects to the URL of line 3 and this web server executes line 6 and shows me the IP address of the web server.

I realize that this can also be done by a simple ping, but in mine the detour via line 6 is necessary.
Related categories: Python Linux Network Administration