3

This site has an "export as csv" button next to the "Power and Energy" text. This is the link of that button which can be found on browser's developer tools (Note that the link changes every 15 minutes)

My question is, is there any way to get that link using python without opening the browser? (I.e. without using selenium because it would take time if I did this for multiple sites.)

My goal is to automate the process of downloading that CSV file, every 1 hour.

8
  • If without opening browser why Selenium? Commented Sep 1, 2019 at 19:45
  • 1
    Sorry, by mistake. Removed the tag. Commented Sep 1, 2019 at 19:50
  • Selenium with headless mode? Commented Sep 5, 2019 at 14:04
  • Well its basically selenium again so the overall time would be only slightly improved I guess. Commented Sep 7, 2019 at 9:39
  • Which tab of the chart? Day, month, year? I found js that could form the url but I need to know which chart you want. Commented Sep 13, 2019 at 22:43

2 Answers 2

6
+100

That url works in curl. Therefore the data doesn't depend on javascript and you do not need selenuim. The st and et are unix time:

datetime.datetime.utcfromtimestamp(1567296000000/1000)

The timeUnit=4 is daily, so making that request hourly is wasting the site's resource and yours. If you really need hourly, change time timeUnit=3 and pn0=Power. Energy=Power x Hr

Lastly, I assume that since you are planning to run hourly, you are planning to save the data somewhere. If so, consider adjusting your st and et to only that range you need to further reduce your request size.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes I already followed this approach. Changing the timestamps for the day I want (which is the current day). Thank you.
5

If you open your browsers debugging tools and go to the "Network" tab, you can see web requests as they are being made.

For example, the request for download from the site you linked is:

https://monitoringpublic.solaredge.com/solaredge-web/p/charts/274560/chartExport?st=1567296000000&et=1569887999999&fid=274560&timeUnit=4&pn0=Energy&id0=0&t0=0&hasMeters=false

The various URL parameters mean that that link will probably always point to that specific file (rather than one that is updated over time).

You can use this method to get the links for the other sites as well, but like this one, the URLs will probably point to a link for that specific time.

5 Comments

How can I find that request? I've went through all of the request names, and didn't find the csv file
Open the network tab in the debugging tools and then click on the download button on the webpage. This is what it looks like for me in Firefox. I then right clicked on it and clicked copy url
Thank you. But how could I get those requests using python without opening the browser?
I'm not sure you could. Unless you can find the Javascript that activates when you press the button, but I don't really have experience with things like that
I would accept your answer as well if I was allowed to. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.