Problems using HTTPSConnection with http.client
Question: I'm new to Python and especially to web coding. I'm trying to make a program
that asks for a name and a surname, and then check on Pipl if there is any
result(s). My "tactic" is to directly go to the URL (containing the
information) with the result, without using POST method to complete the fields
of the website. I tried this:

    
    
    import http.client
    name = input("Name: ")
    surname = input("Surname: ")
    url = "pipl.com/search/?q=" + name + "+" + surname + "&l=&sloc=&in=5"
    conn = http.client.HTTPSConnection(url, 443)
    conn.putrequest('GET', '/')
    conn.endheaders()
    r = conn.getresponse()
    print(r.read())
    

And I'm getting this error:

> socket.gaierror: [Errno -2] Name or service not known

I think that's because I don't only use the domain name (pipl.com), but
nothing helps me, I still stuck here.

I also told myself that using POST will be maybe easier. I repeat, I'm very
new to web coding (and I don't have the best English), I'm learning, so thanks
for your help !


Answer: The best way by all means is using the PIPL code libraries. Still, if you want
something that's more "quick and dirty", use the python 'requests' library
(<http://docs.python-requests.org/en/master/>) which can be installed with pip
and gives you what you need with ease. I took your initial code and came up
with this:

    
    
    import requests
    name = input("Name: ")
    surname = input("Surname: ")
    url = "http://api.pipl.com/search/?first_name=" + name + "&last_name=" + surname + "&key=sample_key"
    response = requests.get(url)
    print (response.json())
    

The end results is the json response from the API. Read more about the API
possible responses at <https://pipl.com/dev/reference/#response>

