How to connect to Remote server using python

Hi Team,
We are working on python script which connects to remote server .
We have explored winrm library , but there are some settings to be done on remote server to allow winrm library to work.
Let me know if there is any other option for us to connect to remote server without any setting/code to be run on server machine.
Thanks in Advance!

[posting updated]

It depends on what service said server is running.

In this example, a connection is made to a http server and the response saved as response.html:

import socket

target_host = "192.168.1.1"  # ip address or URL
target_port = 80

# create a socket object and handler
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client:
    # connect the client
    client.connect((target_host, target_port))
    
    # send some data
    data = bytes(f"GET / HTTP/1.1\r\nHost: {target_host}\r\n\r\n", 'UTF-8')
    client.sendall(data)
    
    # receive some data
    response = client.recv(4096)
    
    # create a file handler for the output
    with open("response.html", mode='w', encoding='UTF-8') as output:
        print(response.decode(), file=output)

print("Script exit")

I hope this helps (on some level).

Hi

Which library we can import for this connection purpose.