Forums

How to fetch URL periodically

I have a script running on another server which needs a cron job to trigger it periodically. I thought it would be easy to set this up here but it's proving difficult. I am on the Hacker account level.

The instructions from the script are that I need to make two cron jobs to do this: CRON JOB 1 Fetch a URL every 24 hours

CRON JOB 2 Fetch a URL every 2 minutes

I don't think we have access to cron on pythonanywhere, right? Is the Scheduled Tasks feature the equivalent? If so, can I use it to just fetch a URL? To do that, do I need to set up a python script that can be run for each fetch? What syntax should I use in python to do this?

I don't actually need the contents of the fetched URLs. It's just a trigger to tell the script to do something.

Possibly important: the URL is https.

hi, i also need this type of coding mcdvoice & mybkexperience

Scheduled tasks can be used for intervals of an hour or a day only. If you need more granular timing, you can use an always on task that just loops forever doing the thing you want and then pausing for the interval that you want between runs.

Thanks for the advice about the granular timing. I'll look into it.

I am wondering though, this code is what I'm using which looks correct but doesn't seem to be working in that the script is no responding to it. Can you tell me if this should be working?

import requests as reqs
response = reqs.get('URL')

I'm not sharing the URL for security but it's along the lines of https://domain.ca/path/?key=123&action=trigger

What happens? (on both sides)

I have the exactly same issue. Could you solve the issue by now?

What issue are you having? There are a number of issues discussed in this thread.

It's solved. My fault - some wrong URL in production environment. Feel free to delete my question.

Glad to hear that you made it work!