I want to use curl to download the latest version of this file. The site has a robots.txt, however, which is what I think is stopping me from just using
curl -L -z WorldGuard.zip http://www.curse.com/server-mods/minecraft/worldguard/download to get it. There is a direct link
http://addons.curse.cursecdn.com/files/684/741/worldguard-5.7.3.zip to the file which is located in the html source code of the page and I can use this link to curl it since this link is not a permalink, I need to find a way to obtain this url from the first link (which is a permalink).
If I use
curl -L http://www.curse.com/server-mods/minecraft/worldguard/downloadI end up with this as the output. I've tried using
FOR /F "skip=628 tokens=10,11,12,13,14 delims=/ " %%a in ('curl -L http://www.curse.com/server-mods/minecraft/worldguard/download') DO curl -z foo.zip %%a') but I there appears to be a limit to how many lines I can skip (similar to the token limit of 31) and it would probably have given me all the lines after that as well (not what I want).
Next, I tried saving the output to a text file and deleting all lines except the one I want, however, I don't know how to delete lines that don't contain a specific string. I was thinking of only focusing on lines that had
"http://addons.curse.cursecdn.com/files/" (in other words, the line that had the url I wanted), but I have no idea how to do that.
How can I obtain just the url (or the part that changes:
684/741/worldguard-5.7.3.zip) and, hence, get curl to download it?
Edit: I am open to alternatives if there is no easy way of doing it in a batch script and/or using curl. I am willing to accept answers that use visual basic (.vbs.), powershell or anything that can be executed from a batch file (which should be nearly everything). I'd still prefer using batch and curl to keep it consistent and in one file, and because I already have 90% of what I want in batch. Also, I am not that familiar with things that aren't batch so I'd prefer it if you explain what the script does.