Use Chrome's / Firefox's dev-tools in python

Chris Angelico rosuav at gmail.com
Fri May 21 18:07:07 EDT 2021


On Sat, May 22, 2021 at 3:55 AM max pothier <contact.tarneo at gmail.com> wrote:
>
> Hello,
> Thanks for you answer!
> Actually my goal is not to automatically get the file once I open the page, but more to periodically check the site and get a notification when there's new homework or, at the morning, know when an hour is cancelled, so I don't want to have to open the browser every time.
> I have pretty good javascript knowledge so if you could better explain that idea, it would be a great help.
>

Ahh, now I better understand your purpose. Hmm.

First and by far the best option would be to see if there's any sort
of (documented or undocumented) API. See if you can figure out how the
requests are being done, and try to find a pre-request request that is
hinting at the download address. (You might have to do some
exploration here.)

Secondly, it may be possible to do an occasional manual check, but
then keep your login cookie alive by periodic queries by your
automated script. No idea how well that would work.

Third, your worst case might be to do most of the work in JavaScript,
maybe as a Chrome extension, but then have it call a Python script
(via an HTTP request, since that's how JavaScript in a browser can
best notify anything) to do whatever extra work you need Python for.
Not sure how well that would work.

Unfortunately it depends a LOT on the homework server you're working
with, so it's hard to be specific. On the plus side, though, you're
going to learn all kinds of things along the way! Or maybe that's
another downside, depending on how Daily WTF-worthy the site is....

ChrisA


More information about the Python-list mailing list