pythondnspython

DeprecationWarning: please use dns.resolver.Resolver.resolve()


When using dns.resolver.Resolver() it returns a warning that I should use dns.resolver.Resolver.resolve ()

When I changed it, it further gives error:

TypeError: resolve() missing 2 required positional arguments: 'self' and 'qname'

This is the code:

        # my_resolver = dns.resolver.Resolver()
        my_resolver = dns.resolver.Resolver.resolve()
        answers = my_resolver.query(host, "A")
        answer_txt = my_resolver.query(host, "TXT")

Any suggestions to fix this?


Solution

  • faced the same problem

    You should remove .resolve from my_resolver = dns.resolver.Resolver.resolve() and replace my_resolver.query() with my_resolver.resolve()

    Example:

        my_resolver = dns.resolver.Resolver()
        answers = my_resolver.resolve(host, "A")
        answer_txt = my_resolver.resolve(host, "TXT")