2

I got this code for whois lookup from here.

but i am getting raw data or html data .. i am getting an output but not in readable format like in json or xml .. how i can convert this into json .. pasting a example output

ttmm.com domain lookup results from whois.ename.com server:

enter code here Domain Name: ttmm.com
Registry Domain ID:
Registrar WHOIS Server: whois.ename.com
Registrar URL: http://www.ename.net
Updated Date: 1998-11-25 T05:00:00Z
Creation Date: 1998-11-25 T05:00:00Z
Registrar Registration Expiration Date: 2016-11-24 T05:00:00Z
Registrar: eName Technology Co.,Ltd.
Registrar IANA ID: 1331
Registrar Abuse Contact Email: abuse@ename.com
Registrar Abuse Contact Phone: +86.4000044400
Domain Status: clientDeleteProhibited
https://www.icann.org/epp#clientDeleteProhibited
Domain Status: clientTransferProhibited             https://www.icann.org/epp#clientTransferProhibited
 Registry Registrant ID:Not Available From Registry
Registrant Name: chousteven
Registrant Organization: hua you
Registrant Street: an yuan cun daxue cheng
Registrant City: ping xiang shi
Registrant State/Province: jiang xi
Registrant Postal Code: 337000
Registrant Country: CN
Registrant Phone: +86.15979220355
Registrant Phone Ext:
Registrant Fax: +86.15979220355
Registrant Fax Ext:
Registrant Email: stekiss@163.com
Registry Admin ID:Not Available From Registry
Admin Name: chousteven
Admin Organization: hua you
Admin Street: an yuan cun daxue cheng
Admin City: ping xiang shi
Admin State/Province: jiang xi
Admin Postal Code: 337000
Admin Country: CN
Admin Phone: +86.15979220355
Admin Phone Ext:
Admin Fax: +86.15979220355
Admin Fax Ext:
Admin Email: stekiss@163.com
Registry Tech ID:Not Available From Registry
Tech Name: chousteven
Tech Organization: hua you
Tech Street: an yuan cun daxue cheng
Tech City: ping xiang shi
Tech State/Province: jiang xi
Tech Postal Code: 337000
Tech Country: CN
Tech Phone: +86.15979220355
Tech Phone Ext:
Tech Fax: +86.15979220355
Tech Fax Ext:
Tech Email: stekiss@163.com
Name Server: ns1.alidns.com
Name Server: ns2.alidns.com
DNSSEC: unsigned
URL of the ICANN WHOIS Data Problem Reporting System:    http://wdprs.internic.net/
>>> Last update of WHOIS database: 2015-11-19 T12:53:51Z <<<
For more information on Whois status codes, please visit
https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en
Aniket Karne
  • 325
  • 3
  • 14
  • And what have you tried? Show us all some code of what you have tried. – Tigger Nov 21 '15 at 08:59
  • I have given a link for the code. – Aniket Karne Nov 23 '15 at 03:28
  • You can parse this output into json or xml. Or you can use some of the services out there which have APIs for you to download WHOIS data in json or xml format. Some looks free and some is paid service. – Quickpick Dec 30 '15 at 21:28
  • This is extremely easy to do. If you want to do it in PHP, just iterate over it line by line, split it on the colon and then rewrite the line a JSON. Try it and if you can't make it work come back and show up what you tried. – Jim Archer Dec 30 '15 at 22:06
  • @JimArcher Unfortunately, it's not that simple. Not all registrars use that particular format. –  Dec 30 '15 at 22:11
  • @JimArcher yes jim duskwuff said is right not all server are sending data into json or xml . So there is not simple solution for this . – Aniket Karne Dec 31 '15 at 05:46
  • @Aniket Karne Can you share your php code to get this kind whois data using my php script i am not able to domain contact / admin / technical information – Anakbhai Gida Apr 15 '18 at 10:43

5 Answers5

0

Lots of custom parsing. Sorry. There is no simple solution.

There is no standard format for WHOIS responses. At a minimum, most registries have a slightly different format for responses; additionally, "thin registries" such as .COM and .NET require every registrar to implement their own WHOIS server, each of which has its own slightly different, idiosyncratic format.

As others have noted, there are paid APIs available to do this parsing for you. Depending on your needs, this may be a more appropriate solution than trying to parse several thousand different formats yourself.

  • Yes i have tried to do do it myself but it can not be possibile if server is sending data in raw format we can not modify it . Paid api is the key. – Aniket Karne Dec 31 '15 at 05:43
  • This is not true. ICANN does require every registrar to implement a port 43 whois server, but they dictate the format of the whois output in great detail. If you telnet to a registrar's whois server on port 43, and send a domain name they sponsor followed by CR/LF, you'll get it back. You can split it on the colon and then parse the other lines. It's quite simple. A paid API may have been useful years ago, before the output format was dictated, but no longer. – Jim Archer Jan 12 '16 at 00:56
  • @JimArcher That is not the case in general. The 2013 ICANN RAA does recommend a format for WHOIS responses, but not all registrars have agreed to that version of the document, so many WHOIS servers still use nonstandard formats. Additionally, ccTLDs are not bound by the ICANN RAA, and most use idiosyncratic formats for WHOIS responses. (Some, like .ES, don't provide public WHOIS at all!) –  Jan 12 '16 at 01:05
  • @JimArcher …Also, some WHOIS servers will heavily rate-limit requests, and will provide abbreviated or no response once you hit that limit. GoDaddy is particularly bad about this. –  Jan 12 '16 at 01:06
  • @duskwuff You have a good point about registries not under ICANN control (lucky them). But when it comes to registrars subject to ICANN, whether they signed the agreement or not, ICANN has a way of bullying registrars to do things they are not obligated to do. I can rant about that al day, but in this case, most registrars I have checked conform to the new standard. – Jim Archer Jan 12 '16 at 18:17
  • @duskwuff As for rate limiting, well I can't fault the registrars for doing that. They typically white list other registrars, but anyone who is not a registrar, who is doing bulk whois queries, is most likely doing so for a nefarious purpose, or at least a purpose contrary to the interests of the sponsoring registrar. – Jim Archer Jan 12 '16 at 18:17
  • @duskwuff I own a registrar, and I can say with confidence that RAA changes are a big deal as soon as ICANN decides to make a big deal out of it (which is anytime they get a complaint or just feel like it), and 2, GoDaddy does not care about much at all, they seem to do what they want. Anyhow, it sounds like we really don't disagree much. – Jim Archer Jan 13 '16 at 17:01
0

With json you can't store whois output, but you can with

website = whois.whois(input("Website: ")) open("output.json", "w") as f: f.write(str(website)) save the output...

Tarzan
  • 1
  • 1
0

It has been years, but if anyone looking for a solution, then here it is

As far as I know, you cannot take the list and convert it into an array. PHP doesn't recognize the separations as key-value pairs. However, there are some alternative ways through which you can transform the list into an array.

This requires additional work, but if that's what you want, you can try these options

Option 1

Use an online tool such as https://arraythis.com/ to achieve this. Paste your list, and it will be converted into an array. However, you may still need to make some edits to ensure the array is in the correct format.

If I input this

foobar
foobar: bar

I get this

array("foobar", "foobar: bar")

But I want this

array("foobar", "foobar" => "bar")

If you want an associative array, then you must utilize a regular expression to replace the colon with the double arrow operator => and enclose the strings in quotes. If this seems like a lot of effort, consider giving Option 2 a try.

Option 2

Copy and paste the text into any text editor, then proceed to find and replace all the colons with tabs (spaces).

Visit the website https://tableconvert.com/ and paste your data; this will generate an output in the form of a table. Scroll down to choose the 'JSON' option, which will provide an output.

[
    {
        "enter code here Domain Name": "Registrar WHOIS Server",
        "ttmm.com": "whois.ename.com"
    },
    {
        "enter code here Domain Name": "Registrar URL",
        "ttmm.com": "http://www.ename.net"
    },
    {
        "enter code here Domain Name": "Updated Date",
        "ttmm.com": "1998-11-25 T05:00:00Z"
    },
    {
        "enter code here Domain Name": "Creation Date",
        "ttmm.com": "1998-11-25 T05:00:00Z"
    },
    {
        "enter code here Domain Name": "Registrar Registration Expiration Date",
        "ttmm.com": "2016-11-24 T05:00:00Z"
    }
]
Dexter
  • 7,911
  • 4
  • 41
  • 40
-1

I'm running a whois API service (https://websiteapi.com/) and the variety of the responses between registries surprised me everyday until handling them all.

Besides the lack of a common format, a given registry returning inconsistent formats is really hard to handle when not using such a service that handles these cases.

umutm
  • 2,832
  • 4
  • 22
  • 22
-3

split text to lines. read each line. check each line for expire keyword. if found try to return the required.

Krishan Kumar
  • 394
  • 4
  • 13