It's easy for Rapidshare. You can use their API system.

Code: 
subroutine=checkfiles_v1
Description:	Gets status details about a list of given files. (files parameter limited to 3000 bytes. filenames parameter limited to 30000 bytes.)
Parameters:	files=comma separated list of file ids
		filenames=comma separated list of the respective filename. Example: files=50444381,50444382 filenames=test1.rar,test2.rar
		incmd5=if set to 1, field 7 is the hex-md5 of the file. This will double your points! If not given, all md5 values will be 0
Reply fields:	1:File ID
		2:Filename
		3:Size (in bytes. If size is 0, this file does not exist.)
		4:Server ID
		5:Status integer, which can have the following numeric values:
			0=File not found
			1=File OK (Anonymous downloading)
			3=Server down
			4=File marked as illegal
			5=Anonymous file locked, because it has more than 10 downloads already
			50+n=File OK (TrafficShare direct download type "n" without any logging.)
			100+n=File OK (TrafficShare direct download type "n" with logging. Read our privacy policy to see what is logged.)
		6:Short host (Use the short host to get the best download mirror: http://rs$serverid$shorthost.rapidshare.com/files/$fileid/$filename)
		7:md5 (See parameter incmd5 in parameter description above.)
Reply format:	integer,string,integer,integer,integer,string,string
What this basically is is the info of the file you want to get.

Using this random file from Katz as an example

Code: 
http://rapidshare.com/files/411931722/qbqbspbdiujnfgpsboojijmbujpogou.rar
You have two id parts. The file number which is 411931722 and the file name which is qbqbspbdiujnfgpsboojijmbujpogou.rar

Adding the file number, name and the sub above you'll get a string like this:

Code: 
http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=411931722&filenames=qbqbspbdiujnfgpsboojijmbujpogou.rar
This returns lots of info about the file including it's size. You can use something like file_get_contents to get the data and exploxe the , (commas) and easily get the $match[2]

For other file hosts (with the exception of SendSpace who also have an api system) you'll have to cURL the page and get the size using regex with is a bit of a balls, a lot slower and way less accurate.


Noobs guide:

Click this link and it returns funny stuff:
http://api.rapidshare.com/cgi-bin/rs...jmbujpogou.rar