urllib.request.FancyURLOpener is deprecated, what is better method?
Asked Answered
S

0

6

I have been using urllib.request.FancyURLOpener() to retrieve images from URLs. My code is something like this:

class MyOpener(FancyURLopener):
    version = "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"

myopener = MyOpener()

myopener.retrieve(source_url, saved_img_path)

However, when I instantiate a MyOpener() object, I get the following warning:

DeprecationWarning: MyOpener style of invoking requests is deprecated. Use newer urlopen functions/methods

What method(s) should I be using instead?

Stamm answered 10/6, 2020 at 16:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.