Archive: Parsing File Links on a Webpage


Parsing File Links on a Webpage
Hello,

I've been working on making a "latest Sourcemod + Metamod" installer, but reading their RSS was a misery and thought to grab the url instead from one of their mirrors.

But I just don't know how to read it the file versions (http://sourcemod.steamfriends.com/files ) and compare them in-order to get the latest version.

Thanks!


If the numbers in version strings go from 0 to 9 then simply do this (pseudo-code):

declare_variable MaxVersion is 0

while(not end)
{
read_line into Variable // line - "mmsource-1.9.2-windows.zip"
declare_variable Version

// Now parse read Variable:
for(I is 0 to length of Line)
{
get_character at position I
if character_is_numeral // allow only 0 .. 9
Append Character to Version
}
// In this point you have number - "192"
if MaxVersion is less or equal Version
set MaxVersion to Version
}

// Now you have found the largest version - 192

As you can see it is pretty simple but you should store e.g. whole string "mmsource-1.9.2-windows.zip" or do additional steps to recognize mac/linux/windows edition and so on.