thp / urlwatch

Watch (parts of) webpages and get notified when something changes via e-mail, on your phone or via other means. Highly configurable.
https://thp.io/2008/urlwatch/
Other
2.81k stars 352 forks source link

Watching webpage that needs a session cookie #748

Closed kjabl closed 1 year ago

kjabl commented 1 year ago

Is it possible to watch a website that needs an actual session cookie which is valid only once? I want to watch the result of the form on this site: https://rathaus.dortmund.de/antragsstatusausweis/statusrequest.jsf The problem is when you open this webpage a session cookie is set which is valid only once for submitting the form. So Urlwatch would need to first access this site, save the cookie and then send the post data for the form.

Is there a way to achieve this?

thp commented 1 year ago

If you can write a script using mechanize or some other tool, you can integrate that script using the shell job type. Since this sounds very specific to that page, I don't think it's something that we can easily implement in a generic way.

As the URL sounds like it's something of public interest, maybe there's a way to just ask them to provide a nice API that you can call instead?

kjabl commented 1 year ago

Thx for your answer. Mechanize looks really interesting. In the meantime I investigated further. I found a tool which can do this. It's called changedetection. BUT it's a lot more heavyweight then urlwatch. I thin urlwatch is great because its simple and lightweight.

Changedetection makes use of a browser for opening pages and analysing that. The benefit is that you can even execute javascript. But therefore it's a lot more complicated to set up. For me it was two docker containers, one for the browser engine and one for the tool and they have to talk to each other and so on...

This special job can be done quite simple, the final call can contain the form data as post body. All you need is the session cookie from the first call which is valid only for some minutes, so you can't set static cookie data. But I think you're right. This is very special and I'm not sure if it can be abstracted to be generalised for configuration.