Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket Error: [Errno -2] Name or service not known TypeError: must be str, not bytes #139

Open
mrgloom opened this issue Jan 26, 2018 · 3 comments

Comments

@mrgloom
Copy link

mrgloom commented Jan 26, 2018

With python-whois==0.6.8

What does TypeError: must be str, not bytes mean?

w = whois.whois('https://ura.news/news/1052315861')
Socket Error: [Errno -2] Name or service not known
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/miniconda3/lib/python3.6/site-packages/whois/__init__.py", line 40, in whois
    text = nic_client.whois_lookup(None, domain.encode('idna'), 0)
  File "/home/user/miniconda3/lib/python3.6/site-packages/whois/whois.py", line 189, in whois_lookup
    result = self.whois(query_arg, nichost, flags)
  File "/home/user/miniconda3/lib/python3.6/site-packages/whois/whois.py", line 134, in whois
    nhost = self.findwhois_server(response, hostname, query)
  File "/home/user/miniconda3/lib/python3.6/site-packages/whois/whois.py", line 78, in findwhois_server
    match = re.compile('Domain Name: ' + query + '\s*.*?Whois Server: (.*?)\s', flags=re.IGNORECASE|re.DOTALL).search(buf)
TypeError: must be str, not bytes
@Eduard-gan
Copy link

Got the same error while trying to query domain name in .group zone. Found no answers

@YaokaiYang-assaultmaster

I think you cannot pass in the full url into the function. And you cannot include protocol part of the url. So in your case, should query for ura.news. Plus, you should use python-whois.get_whois() for the query.

@Ni-Knight
Copy link

You should use get_whois. This is a Python 3.6 error, as the response from the whois server is a byte stream and not a string then using a regex is not permitted. No clue if this was fixed by now. The library has some more issues with regex in Python 3.6 and up (I had an error in the regex preprocess in parse.py line #205 the string was missing an extra \ in two places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants