Python Forum

Full Version: help about requests download
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am try to use requests.get to download a file named list.csv. However, after I downloaded it. I found I got a wrong result. I got a result with such information.
What's happened?

<!DOCTYPE html>
<html>

<head>
<script type="text/javascript">
var url = '/account/login/';
if (window.location.href.indexOf('service=') != -1) {
url += '?next=' + encodeURIComponent(window.location.href)
}
window.location.href = url;
</script>
</head>

<body>
</body>

</html>
The requests module can't handle JavaScript.
Use Selenium to get HTML of the web page and scrap the link from it or just download the file with Selenium itself.

How to use Selenium to scrape a webpage: https://python-forum.io/Thread-Web-scraping-part-2
Here are two links I found in a hurry, how to set some options for Firefox in order to download the file/link into the desired directory:
http://allselenium.info/file-downloads-p...webdriver/
https://www.automationqc.com/firefox-pro...er-python/

I didn't think about it until now so I'm going to see them both too.