I'm trying to use the Python requests module to download an mp4 video off a website behind a paywall. Here's my code:
link_href = # Found the mp4 link on the website
with open('D:/filename','wb') as f:
response = requests.get(link_href)
f.write(response.content)
I looked at the response.content and it's the html for the site's login page. How do I get the mp4?
ok, seems like you're trying to download an mp4 video from a website that requires login first. The website's login page HTML is returned because you're not providing any login credentials in your request. To get through the paywall, you need to authenticate yourself using the correct login procedure, such as sending a request with your login credentials to the login endpoint.
Below, ill show you a general outline of how to handle the situation using the requests module example of the solution:
You can have an idea of how you can fix your code with this above, if any errors , reply me