Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help about requests download
#1
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>
Reply
#2
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.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  POST requests - different requests return the same response Default_001 3 1,939 Mar-10-2022, 11:26 PM
Last Post: Default_001
  Requests module get() incomplete download bobzarm 2 2,523 Feb-17-2021, 04:51 PM
Last Post: bobzarm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020