Page 1 of 1

Getting all pages from URL + emulate postback from asp.net

Posted: Mon Aug 07, 2006 8:03 am
by carabutnicu
Hello,


what I have:
$url = 'an_url_that_points_to_the_first_page_of_the_site';
$pageContent = stream_get_contents( fopen($url,'r') );


so till now I have the first page I need from the site.
Looking in the page source I understand that it is written in ASP.NET, and to navigate to next page is used the 'postbak' mechanism of the ASP.NET.

In the $pageContent (or page source) there is a INPUT of type='hidden" that stores the number of current page.
When you want to navigate to next page by pressing corresponding link, the postaback is changing the value for that input and makes the request.

So as I understand there is no POST used, to indicate the page number that I can use it too to get in my $pageContent the next page.



question:
What I do to get all pages (for ex: 5 of them), and have them consecutively in $pageContent ? because there is no user input and there is no JS code accepted since the php core runs on server only.



If I have some misunderstanding , I'm open to corrections.

Posted: Mon Aug 07, 2006 3:58 pm
by carabutnicu
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


ok, I finnaly got to know how this postpack works so it turns out that it is using the POST to make a POST based request to the server.
That's fine.  

Now I would have a question like:

having this: 
[syntax="html"]<input type="hidden" name="UsedCount" value="(2236)" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__PageHeight" value="0" />
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="ExpiredCount" value="(67028)" />
<input type="hidden" name="HotNameCount" value="(0)" />
<input type="hidden" name="__ScrollLeft" value="0" />
<input type="hidden" name="hidServerName" value="DNAWEB03" />
<input type="hidden" name="__ScrollTop" value="0" />
<input type="hidden" name="__PageWidth" value="0" />
........etc

and having this:[/syntax]

Code: Select all

function requestDataUsingPOST( $socket, $uri, $data, $host )
	{
		$postString ="POST $uri  HTTP/1.1\r\n";
		$postString.="Host: $host\r\n";
		$postString.="User-Agent: Mozilla\r\n";
		$postString.="Content-Type: application/x-www-form-urlencoded\r\n";
		$postString.="Content-Length: ".strlen($data)."\r\n";
		$postString.="Connection: close\r\n\r\n";
		$postString.=$data;
		
		fwrite( $socket, $postString );
		
		$response = '';
		while( !feof($socket) )
			$response.= fgets( $socket, 128 );

		return $response;
	}



where and HOW I put/insert all the <input> stuff into a POST request ?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Aug 07, 2006 4:00 pm
by feyd
I'd use cURL.

Posted: Mon Aug 07, 2006 5:14 pm
by carabutnicu
Yes, sorry with the issue about posint the code in a worng way.

How I do that with the libCURL ? still how I can do this in a 'raw' mode if I can say that ?