-4

Is there any way to find a specific website for the download link if it changed?. It's hard to explain it by words but I'll try.

Let's say this is the WinRar website and this is its current download link.

I'll download it using this code:

Directory.CreateDirectory("C:\\Winrar");
WebClient WClient = new WebClient();
var WinRar = "https://www.win-rar.com/postdownload.html?&L=0";
WClient.DownloadFile(WinRar, "C:\\Winrar");
WClient.Dispose();

But what if WinRAR updates? What if it changed its download link? How will I autodetect that and change the WinRar variable to its new download link?

Thanks :)

Edit: I meant to say that if the link changes in the WinRAR site. It would detect it. Sorry for the confusion :)

  • 1
    The solution is hard to explain as well. – Soner from The Ottoman Empire Nov 04 '19 at 11:09
  • You're describing what you think the solution would look like. What is the *actual* problem? If you want to find whether an application version changed, checking the *site* won't help at all. The site can change eg if the *ads* it displays change. The solution in this case is to check with a package manager, eg Chocolatey to see what's the latest version, or even get a list of all versions of a specific package – Panagiotis Kanavos Nov 04 '19 at 11:21
  • If you want to check if a *page* changed, one way is to store and use its [ETag](https://en.wikipedia.org/wiki/HTTP_ETag). That's already used by caches and proxies to server cached versions and only hit the server if the ETag in a request is different from the stored one. – Panagiotis Kanavos Nov 04 '19 at 11:23
  • 1
    Welcome to StackOverflow. You need to narrow in your problem, because in theory, anything could happen to the WinRAR site. They could change the name of both the site and file, to something completely different. You would never be able to auto detect that. Maybe it is enough to simply detect if something in the link changes and then throw a notification e-mail to you? That would be a lot simpler to work with. – Jakob Busk Sørensen Nov 04 '19 at 11:39
  • Yes, this. When the link changes its gonna print on the console that the link changed. sorry for not wording or explaining it right – TrueVanguard Nov 04 '19 at 13:27

1 Answers1

0

I think thing that you want to do is not something that much easy and I am not sure even you can do this houndret percent. But I think parsing html and finding links and than choose link that you need may be an option.

In this question they disccuss about parsing html and finding links that may be useful for you.

There is a similar implemantation here that may helps you.

nzrytmn
  • 6,193
  • 1
  • 41
  • 38