MPCodeWriter21 / whois21

whois21 is a simple and easy to use python package that lets you easily query whois information of a domain/IP.
Apache License 2.0
26 stars 1 forks source link

Correctly select the result #4

Closed Hugz59 closed 1 year ago

Hugz59 commented 1 year ago

Hey,

I would like to use your package for my tool but i don't know who to have a good display of the result.

In my tool, when i call your function, i have this :

whois

I would like each result to have its own line so that it is clearer but impossible to do.

I want a result like this :

whoisbg

This is my code :

domain_whois = whois21.WHOIS(domain_name)

return render(request, 'toolbox/whois.html', {'whois' : domain_whois})

I'm using Django for my tool.

Any idea ?

Thx !

MPCodeWriter21 commented 1 year ago

Hi there!

It looks like you put the raw data directly into your html data and the whitespaces in the data were trimmed. You could put the raw data in special tags such as pre and textarea that treat whitespaces differently. textarea pre

You can also try replacing '\n' with '<br>' in the raw data.

But if you want the specific information you mentioned in the second image, You could do something like the code below. (You should actually put it directly in your html template so that you don't have to use |safe)

def foo(request):
    ...
    whois = whois21.WHOIS(domain_name)

    whois_data = f"""
    Domain Name: {whois_data.domain}<br>
    Registrar: {', '.join(whois_data.registrar_name)}<br>
    Creation Date: {whois_data.creation_date}<br>
    Expiration Date: {whois_data.expires_date}<br>
    Name Servers: {', '.join(whois_data.name_servers)}<br>
    Status: {whois_data.status}<br>
    Emails: {', '.join(whois_data.emails)}<br>
    Updated Date: {whois_data.updated_date}<br>
    """

    return render(request, 'toolbox/whois.html', { 'whois' : whois_data })

Additional Note: Make sure you're using the latest version:

$ python -m pip install -U whois21
Hugz59 commented 1 year ago

Hey !

Oh thanks you save my life !

I didn't think to use the

 tag. 

I wanted to return all datas of the whois. It's working now.

Thank you very much !