Server IP : 85.214.239.14 / Your IP : 3.144.242.149 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/root/proc/3/task/3/cwd/proc/2/task/2/cwd/usr/share/doc/python3-dnspython/examples/ |
Upload File : |
#!/usr/bin/env python3 # # This is an example of sending DNS queries over HTTPS (DoH) with dnspython. # Requires use of the requests module's Session object. # # See https://2.python-requests.org/en/latest/user/advanced/#session-objects # for more details about Session objects import requests import dns.message import dns.query import dns.rdatatype def main(): where = "1.1.1.1" qname = "example.com." # one method is to use context manager, session will automatically close with requests.sessions.Session() as session: q = dns.message.make_query(qname, dns.rdatatype.A) r = dns.query.https(q, where, session=session) for answer in r.answer: print(answer) # ... do more lookups where = "https://dns.google/dns-query" qname = "example.net." # second method, close session manually session = requests.sessions.Session() q = dns.message.make_query(qname, dns.rdatatype.A) r = dns.query.https(q, where, session=session) for answer in r.answer: print(answer) # ... do more lookups # close the session when you're done session.close() if __name__ == "__main__": main()