Page 1 of 1

Simulate click and get new page contents

Posted: Thu Jul 13, 2006 11:39 pm
by arachaz
hi,

I am using oop with php to view a web site with many pages.There is 4 buttons for navigation from page to page. Here is my code:

1 //create a browser object:
2 $b = new COM("InternetExplorer.Application");
3 //navigate to page
4 $serv = 'http://www...../*.asp?MyCode=97';
5 $b->visible = 1;
6 $b->navigate($serv);
7 //wait for the page to be completly loaded
8 $i=0;
9 while ($b->readyState!=4) {
10 $i++;
11 }
12 //create a document object:
13 $doc = $b->document;
14 // Get buttons objects in an array
15 $btn = $doc->getElementsByName('PagingMove');
16 // Simulate a click on the next button (">")
17 $btn[2]->click();
18 $j=0;
19 while ($b->readyState!=4) {
20 $j++;
21 }
22 echo $j";
23 //create a new document object:
24 $newdoc = $b->document;
.....

up to line 17 all is ok and if using command line, the new clicked page appears on the ie browser. But I dont know how to implement a new browser object to embed the new clicked page.
The $b browser object is not refreshed after line 17 and the $newdoc is not refering to the new page but still to the old one.

My questions :
1-- How to implement the new page in a browser object (the link is an asp one so there is no transparent URL)
2 --How to transfer the content of the new clicked page to a file for example?

Many thanks for you all

Arachaz

Posted: Fri Jul 14, 2006 1:32 am
by RobertGonzalez
Can you do everyone here a favor and use the

Code: Select all

bbcode tags? It is really hard to read your code when it is just plain text on the screen. Thanks.

Posted: Fri Jul 14, 2006 10:31 am
by arachaz
I thought it would be most clear to numerate the lines. Anyway your remark is judicious.

Thanks.

Posted: Fri Jul 14, 2006 10:32 am
by dull1554
for my sake

Code: Select all

1 //create a browser object:
2 $b = new COM("InternetExplorer.Application");
3 //navigate to page
4 $serv = 'http://www...../*.asp?MyCode=97';
5 $b->visible = 1;
6 $b->navigate($serv);
7 //wait for the page to be completly loaded
8 $i=0;
9 while ($b->readyState!=4) {
10 $i++;
11 }
12 //create a document object:
13 $doc = $b->document;
14 // Get buttons objects in an array
15 $btn = $doc->getElementsByName('PagingMove');
16 // Simulate a click on the next button (">")
17 $btn[2]->click();
18 $j=0;
19 while ($b->readyState!=4) {
20 $j++;
21 }
22 echo $j";
23 //create a new document object:
24 $newdoc = $b->document;

Posted: Fri Jul 14, 2006 11:21 am
by onion2k
Use Curl.

Posted: Sat Jul 15, 2006 4:21 am
by arachaz
I never used curl before. Can you explain how.

Thanks

Posted: Sat Jul 15, 2006 8:58 am
by feyd
Have a read through the manual. If you have further, more specific, questions on its usage, please post back.