开发者

sending action=updatenow to server through cronjob?

开发者 https://www.devze.com 2023-04-04 19:03 出处:网络
I am a member of a site, where stats from a game is collected every time I visit the site, when I press the update button.. I would like this to happen once a day automatically, and I\'ve been told th

I am a member of a site, where stats from a game is collected every time I visit the site, when I press the update button.. I would like this to happen once a day automatically, and I've been told that this should be possible through a cronjob...

the page is : http://bfbc2.statsverse.com/stats/ps3/ChiefOfVikings/

the tricky part is, that the update is triggered by a javascript.. but as far as I can tell, the javascript is only this:

$.ajax(
  {
    type:"POST",
    data: { action: "updatenow"开发者_如何学Python },
  })
}

(not sure though)

Can anyone help me find any way of the update being triggered automatically once a day through a cronjob?


You can do this with curl. Curl allows you to construct url GETs and POST to mimic a browser action (other HTTP types are also supported). You could get curl working by doing something similar to:

curl -L -i -v -c sitecookie.txt -b sitecookie.txt -d action=updatenow http://bfbc2.statsverse.com/stats/ps3/ChiefOfVikings/

The options are

  • -L = follow redirects (HTTP 301 or 302)
  • -i = include the HTTP header returned from the server in the output
  • -v = verbose
  • -c sitecookie.txt = write cookies to sitecookie.txt
  • -b sitecookie.txt = read cookies from sitecookie.txt when sending data to the url
  • -d action=updatenow = HTTP POST action=updatenow to the url

You may also need -k if the server is HTTPS encrypted. See the curl manpage for more options and documenation.

One final thing to note, the url you POST to must be the one that the ajax is sending to.

Once you have this working from the command line, put it in a script then run the script from a cronjob every day.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号