Scripting within a browserpage when logged in

Howdy,

What I want to do browse through a range of webpages of a website, extract information (e.g. safe source as file) and go on to the next. The problem is, I need to login to this site. Now I thought I’d just login with e.g. Safari, so the session is open, and then do some Applescript stuff. Unfortunately I’m getting the login window again, so I can’t really test anything. Is there a way to circumvent this?

I started with something like this:


set var1 to 0
set var2 to 0

repeat
	
	set var1 to var1 + 1
	set var2 to var2 + 1
	
	tell application "Safari" to OpenURL "http://www.website.com/?foo=var1&bar=var2"
	
	--save source as file with var1 and var2 name

	if var1 = 10 then exit repeat
	
end repeat

It doesn’t recognize var1 and var2 in the url, but that’s another problem. I hope it’s clear what I’m trying to do. Is someone can give me some pointers, that would be greatly appreciated!