curl-and-php
Problem getting asp form - __VIEWSTATE field
Date: Tue, 17 Jan 2006 01:13:41 +0100
Hi everybody,
I am trying to get a list of result pages from one asp site.
I found it extrange about how it works, and I'd like to ask for some help if
you don't mind.
How the site works:
You get a result page, and then any of the result links 1 2 3 4 ... next 10
link the same page.
So I found it is a form with some normal and hidden fields.
What happens:
I am not able to get any page a part from the first one.
What I did:
I've simulated manually the behavior of the script and checked the
sourcecode of the page.
I have here one VIEWSTATE wich is always the same. I've tried many times.
After that:
I run my script, but the VIEWSTATE I got is different. I suppose it is the
problem.
The code to get the page:
# Define main url
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; es; rv:1.4)
Gecko/20030624 Netscape/7.1 (ax)";
$cookie_file_path = "tcookies.txt";
$url = $domain;
$n=0;
# Cookies generation
while($n<5) {
# Defined parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE,
$cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR,
$cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
# Simulate user behavior
if ($n==0) $url= $domain .
"/busqDirectas/busquedas.html";
if ($n==1) $url= $domain .
"/busqDirectas/comprar/comprar_inmuebles.html";
if ($n==2) $url= $domain .
"/busqDirectas/comprar/Piso_Apartamento/comprar_inmuebles_Piso_Apartamento.h
tml";
if ($n==3) $url= $domain .
"/busq/resultados.aspx?CodParam=IdTipoInmueble.2_IdTipoOferta.2_idProvincia.
43";
$n++;
}
# Get special characters of spanish
$result=utf8_decode($result);
# Show page to check __VIEWSTATE
echo $result;
die();
Domain:
If anyone wants to chek it, domain is www.f#o#t#o$c
<http://www.f/#o#t#o$c&a&s&a.es> &a&s&a.es - Please remove # and &. Is
important from me to hide this url from search engines.
Next code:
After that code I've got the one to get the form, but I think my problem is
here, to get this page with the original VIEWSTATE.
There's some things I can't understand as special characters, binary mode,
etc, of this string of VIEWSTATE.
May be someone could help me.
Thanks in advance,
Sam
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-01-17