Because we are doing some web data set processing, we need to resolve the domain name and organize Ip, so we use
Socket.getaddrinfo.
First, read the domain name from the previously processed domain name dataset
Secondly, loop through them one by one
Do the exception handling
But the results are obviously not as good as they should be, but when you manually put a single domain name in and resolve it, there is no problem.
I think the problem is a newline at the end of server_name.
So I need to remove the ‘\n’
To explain, there are two ways to remove line breaks here.
Method 1: With .sprip(‘\n’)
Method 2: [:-1] (because the line break is always in the last character)
I hope this will help and solve the problem smoothly and instantly.
def get_dns(): domains = DataDispose.get_domain_list() for domain in domains: try: myaddr = socket.getaddrinfo(domain[:-1], 'http') print(myaddr) except Exception as e: print(e) continue
Read More:
- Crawler overtime error socket.timeout: timed out/NameError: name ‘socket‘ is not defined
- [Modified] AttributeError: ‘socket‘ object has no attribute ‘ioctl‘ python linux
- Nltk Library Download error: [errno: 11004] getaddrinfo failed
- Error: [errno 11001] getaddrinfo failed [How to Solve]
- Invalid python sd, Fatal Python error: init_fs_encoding: failed to get the Python cod [How to Solve]
- [Solved] ssl_client_socket_impl.cc handshake failed (Same Codes in Different Environments)
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- Pyinstaller Error: [ImportError]: DLL load failed while importing _socket: Parameter error
- Python Error: pip install mysql-connector-python failed
- [Solved] selenium Error: ERROR:ssl_client_socket_impl.cc(962)] handshake failed; returned -1, SSL
- [Solved] NPM install Error: check python checking for Python executable python2 in the PATH
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- Gunicorn Flask Error: [ERROR] Socket error processing request
- [Solved] Error starting proxy server: oserror (10013), “an attempt was made to access the socket in a way that the access permission is not allowed.”, None, 10013, None)
- [Solved] appium Error: Original error: socket hang up
- Python Error: Failed to establish a new connection: [Errno -2] Name or service not known
- python3 ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833) Error
- [Solved] Odrive gui Error: Do not use the development server in a productioun and supported version of the Socket
- Jupyter notebook Failed to Switch to the Virual Environment: DLL load failed python.exe could not find the entry