Using wget to force cache clear
Asked Answered
D

2

7

I am trying to extract the current date and time from this Wikipedia page (https://en.wikipedia.org/wiki/ISO_8601) using wget in the Windows 10 command prompt. This is for a personal app I am developing, so instead of trying to figure out more complicated c++ (only language I know, and barely) to convert my local time to UTC, then get ordinal dates for my project, I just want to download this page with wget and substring the information I need out of it. The page (when refreshed) has exactly the information I need. I could find another way to do this, but now I am taking it personal and trying to make it a learning experience since it seems it should be simple.

I am posting my script below, but no matter what I do the page is not refreshing when I use wget - it will stay the same unless I open the link in a browser and clear my cache. Shouldn't the script below do this? I tried --no-cache and --no-cookies but no success. Once I open chrome and go to this link (https://en.wikipedia.org/w/index.php?title=ISO_8601&action=purge) and click "purge" I can always use wget right after and it works. I just need this to be automatic without me manually refreshing.

wget --no-check-certificate --no-cache --no-cookies https://en.wikipedia.org/wiki/ISO_8601
Despumate answered 22/8, 2018 at 10:47 Comment(0)
S
22

This will work:

wget --no-check-certificate --no-cache --no-cookies https://en.wikipedia.org/wiki/ISO_8601 --post-data="action=purge"

But forcing the servers at wikipedia to update the cached version of the page across their servers might not be the best way to solve this overall. Since you are programming in C++ you might want to take a look at: Converting Between Local Times and GMT/UTC in C/C++

Seato answered 22/8, 2018 at 15:11 Comment(1)
This worked great (though, in my case, all I needed was --post-data="action=purge")Askari
S
0

Might not be exactly what was asked. For those who came here to download the un-cached file - Unfortunately wget --no-cookies --no-cache doesn't work for me, if you can use curl
Please consider -

curl LINK --output local_file_name

Stillage answered 25/9, 2021 at 6:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.