# Whois lib in python and Knime

**URL:** <https://forum.knime.com/t/whois-lib-in-python-and-knime/38562>\
**Category:** KNIME Extensions\
**Tags:** scripting\
**Created:** [January 4, 2022, 1:21pm UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562 "2022-01-04T13:21:40Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![natanzi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/natanzi/32/50615_2.png) [@natanzi](https://forum.knime.com/u/natanzi)\
**Post date:** [January 4, 2022, 1:21pm UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/1 "2022-01-04T13:21:40Z")

</div>

Dears,  
I read the below topic and try to run it, while I get the below error, and the root cause is not clear

Story:  
I have 25K url ([www.example.com](http://www.example.com)) and I need to get expire date of domains with knime and python

> [@Python library](https://forum.knime.com/t/python-library/29058):
>
> Hello Everyone, Hope you are all well and safe. I wrote a small script in python script (1=\>1) with importing the whois library, but when I am running the script it keeps telling me ModuleNotFoundError. this is the whole error i get while I am running the script: ERROR Python Script (1⇒1) 3:341 Execute failed: No module named ‘whois’ Traceback (most recent call last): File “”, line 2, in ModuleNotFoundError: No module named 'whois Do you have any idea how can I fix this problem? Th…

Does anybody have advice?

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/d/ed620421d7c51d2df22db166510534a6cf199c1f.png)

ERROR Python Script (1⇒1) (deprecated) 0:359 Execute failed: [Errno 2] No such file or directory: ‘C:\ProgramData\Anaconda3\lib\site-packages\whois\…/data\public\_suffix\_list.dat’  
Traceback (most recent call last):  
File “”, line 2, in   
File “C:\ProgramData\Anaconda3\lib\site-packages\whois\__init_\_.py”, line 56, in whois  
domain = extract\_domain(url)  
File “C:\ProgramData\Anaconda3\lib\site-packages\whois\__init_\_.py”, line 102, in extract\_domain  
with open(tlds\_path, encoding=‘utf-8’) as tlds\_fp:  
FileNotFoundError: [Errno 2] No such file or directory: ‘C:\ProgramData\Anaconda3\lib\site-packages\whois\…/data\public\_suffix\_list.dat’

---

<div class="post-metadata">

**Author:** ![LukasS](https://forum-cdn.knime.com/user_avatar/forum.knime.com/lukass/32/27160_2.png) [@LukasS](https://forum.knime.com/u/LukasS)\
**Post date:** [January 4, 2022, 4:41pm UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/2 "2022-01-04T16:41:12Z")

</div>

Hi @natanzi,

I’d advice to use the most recent python scripting nodes with the conda environment propagation node: In your case, it seems like the file  
`C:\ProgramData\Anaconda3\lib\site-packages\whois\…/data\public_suffix_list.dat`  
is missing, which comes with the `whois` installation. With said node, you can make sure that anyone you share the workflow with uses the same environment (i.e. python modules) like you do.

This example workflow should solve the issue:

> **[python\_whois – lukass](https://hub.knime.com/lukass/spaces/Forum/latest/python_whois~wnysxsyQcWDbOdZo)**
>
> Solutions for data science: find workflows, nodes and components, and collaborate in spaces.

I modified the python code slightly so that it takes into account all the rows in the input column.

Kind Regards,  
Lukas

---

<div class="post-metadata">

**Author:** ![natanzi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/natanzi/32/50615_2.png) [@natanzi](https://forum.knime.com/u/natanzi)\
**Post date:** [January 5, 2022, 5:32am UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/3 "2022-01-05T05:32:15Z")

</div>

Dear Lukas,  
Many thanks, Would you please advice fro below error?

![image](https://forum-cdn.knime.com/uploads/default/original/3X/c/5/c54a86ea4d48eeb3870a6c5900e3dbca42eaef45.png)

```auto
ERROR Python Script 3:4 Execute failed: module 'whois' has no attribute 'whois'
Traceback (most recent call last):
  File "<string>", line 9, in <module>
AttributeError: module 'whois' has no attribute 'whois'

```

---

<div class="post-metadata">

**Author:** ![natanzi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/natanzi/32/50615_2.png) [@natanzi](https://forum.knime.com/u/natanzi)\
**Post date:** [January 5, 2022, 6:16am UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/4 "2022-01-05T06:16:20Z")

</div>

Dear Lucas,

I have tried installing both: whois and python-whois but none of them worked for me.  
I found out that the issue is quite common but did not manage to find a fix for it.

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [January 5, 2022, 9:43am UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/5 "2022-01-05T09:43:54Z")

</div>

Dear @natanzi

Please find below an alternative solution based on a different Python library

[https://anaconda.org/rapidsai/python-whois](https://anaconda.org/rapidsai/python-whois)

which can be installed using Conda as follows:

```auto
conda install -c rapidsai python-whois

```

The Python code in -Python Script- node should be robust to Time Out errors (or others) and allows submitting a table with several queries at the same time:

```auto
from pandas import DataFrame

import pandas as pd

import whois

# Create DataFrame 
output_table_1 = DataFrame()

rowID = 0

for ind in input_table_1.index:
	print( ind)
	
	current_row_table = input_table_1.iloc[rowID]

	URL = str( current_row_table['URL'])
	
	print( URL)
	
	try:
		w = whois.whois(URL)
			
		for key, value in w.items():
			# print( key, "->", value)
			current_row_table[key] = str( value)
		  
		current_row_table["Response"] = w.text
		current_row_table["Error"] = ""
			
	except OSError as err:
		print("OS error: {0}".format(err))
		current_row_table["Response"] = w.text
		current_row_table["Error"] = "OS error: {0}".format(err)
		
	if rowID == 0:
		frames = pd.DataFrame( current_row_table)
	else:
		frames = [frames, pd.DataFrame( current_row_table)]
		frames = pd.concat( frames, axis=1)
		
	rowID = rowID + 1

output_table_1 = frames
output_table_1 = output_table_1.T

```

The workflow is available here below:

[20220104 Pikairos Whois lib in python and Knime.knwf](https://forum.knime.com/uploads/short-url/R97svCTXj0uGy6Veah2JSUDdEp.knwf) (95.2 KB)

Hope this helps.

Best

Ael

---

<div class="post-metadata">

**Author:** ![LukasS](https://forum-cdn.knime.com/user_avatar/forum.knime.com/lukass/32/27160_2.png) [@LukasS](https://forum.knime.com/u/LukasS)\
**Post date:** [January 5, 2022, 11:01am UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/6 "2022-01-05T11:01:07Z")

</div>

Hey @natanzi,

sorry, my bad: I forgot to tell the Python Script node to actually use the conda environment. I reuploaded the fixed version:

> **[python\_whois – lukass](https://hub.knime.com/lukass/spaces/Forum/latest/python_whois~wnysxsyQcWDbOdZo)**
>
> Solutions for data science: find workflows, nodes and components, and collaborate in spaces.

If you are interested, the setting is in the Executable Selection Tab:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/f/e/fefdeea6ade7ac1a32e1c7c88a1d53bce6363e20.png)

Kind Regards,  
Lukas

---

<div class="post-metadata">

**Author:** ![natanzi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/natanzi/32/50615_2.png) [@natanzi](https://forum.knime.com/u/natanzi)\
**Post date:** [January 5, 2022, 11:28am UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/7 "2022-01-05T11:28:29Z")

</div>

> [@aworker](#):
>
> `conda install -c rapidsai python-whois`

Dear Lucas,  
Many Thanks for your notification.

BR,  
Milad

---

<div class="post-metadata">

**Author:** ![natanzi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/natanzi/32/50615_2.png) [@natanzi](https://forum.knime.com/u/natanzi)\
**Post date:** [January 5, 2022, 12:27pm UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/8 "2022-01-05T12:27:32Z")

</div>

Dear Ael,  
You made my day, much appreciated.

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [January 5, 2022, 12:45pm UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/9 "2022-01-05T12:45:51Z")

</div>

Dear Milad,

> [@natanzi](#):
>
> You made my day, much appreciated.

My pleasure 😃 !

Just a couple of comments. I thought @LukasS’s solution was using a different library but actually we are using the same. Secondly, there is a minor error in my Python implementation which should be corrected. Where its says

```auto
except OSError as err:
		print("OS error: {0}".format(err))
		current_row_table["Response"] = w.text

```

it should be:

```auto
except OSError as err:
		print("OS error: {0}".format(err))
		current_row_table["Response"] = ""

```

I have corrected it and it is available now in this new version here below:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/d/1/d129edb6b38f94f7cedb9f3fdd945efe166a762e.png)

[20220105 Pikairos Whois lib in python and Knime.knwf](https://forum.knime.com/uploads/short-url/svFZd9Csq6ZvIXJvdg0qQ055NI2.knwf) (98.9 KB)

Best wishes,

Ael

---

<div class="post-metadata">

**Author:** ![natanzi](https://forum-cdn.knime.com/user_avatar/forum.knime.com/natanzi/32/50615_2.png) [@natanzi](https://forum.knime.com/u/natanzi)\
**Post date:** [January 5, 2022, 4:32pm UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/10 "2022-01-05T16:32:22Z")

</div>

@Dear aworker,  
if error happening, the flow stop, How can continue the process and skip the error like the below:

```auto
ERROR Python Script 0:464 Execute failed: No match for "VALIAMR.COM".
>>> Last update of whois database: 2022-01-05T07:49:51Z <<<

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.

Traceback (most recent call last):
  File "<string>", line 22, in <module>
  File "C:\Users\bagher.h\.conda\envs\py3_knime\lib\site-packages\whois\ __init__.py", line 44, in whois
    return WhoisEntry.load(domain, text)
  File "C:\Users\bagher.h\.conda\envs\py3_knime\lib\site-packages\whois\parser.py", line 188, in load
    return WhoisCom(domain, text)
  File "C:\Users\bagher.h\.conda\envs\py3_knime\lib\site-packages\whois\parser.py", line 399, in __init__
    raise PywhoisError(text)
whois.parser.PywhoisError: No match for "VALIAMR.COM".
>>> Last update of whois database: 2022-01-05T07:49:51Z <<<

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.

```

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [January 5, 2022, 4:52pm UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/11 "2022-01-05T16:52:15Z")

</div>

Dear @natanzi

“[WALIAMR.COM](http://WALIAMR.COM)” does not exist as URL. To cover any possible error without distinction, I have added the following piece of code:

![image](https://forum-cdn.knime.com/uploads/default/original/3X/d/7/d751788fd00e88c1d459ef81ed6a0853a9e50cf3.png)

The amended version of the workflow is available here below:

[20220105 Pikairos Whois lib in python and Knime.knwf](https://forum.knime.com/uploads/short-url/2dzdGSbWP9AbLR6eohwFP2rtYox.knwf) (104.2 KB)

Hope this helps

Ael

PS: @natanzi please be aware that you are accessing a service “[whois.com](http://whois.com)” which does not allow intensive quering. This workflow is fine if your aim is to automatically gathering the information of just a few URL 🙂

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [January 9, 2022, 8:38am UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/12 "2022-01-09T08:38:04Z")

</div>

Thanks @natanzi for validating the solution.

Best wishes

Ael

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [January 16, 2022, 8:38am UTC](https://forum.knime.com/t/whois-lib-in-python-and-knime/38562/13 "2022-01-16T08:38:48Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
