I am trying to access a PDF file from a bank's website for PDF mining, but it keeps returning HTTP 403 error. So as a workaround, I am trying to change my User-Agent to a browser for accessing the file (and downloading it).
The code below is part of what I have right now. This returns the following error:
C:\Users\Name\Anaconda3\lib\site-packages\ipykernel_launcher.py:8: DeprecationWarning: MyOpener style of invoking requests is deprecated. Use newer urlopen functions/methods
How do I fix this?
import urllib.request
my_url = 'someurl here'
class MyOpener(urllib.request.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()
page = myopener.open(my_url)
page.read()