Simulate click and get new page contents

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arachaz
Forum Newbie
Posts: 3
Joined: Wed Jul 12, 2006 10:53 am

Simulate click and get new page contents

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
arachaz
Forum Newbie
Posts: 3
Joined: Wed Jul 12, 2006 10:53 am

Post by arachaz »

I thought it would be most clear to numerate the lines. Anyway your remark is judicious.

Thanks.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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;
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Use Curl.
arachaz
Forum Newbie
Posts: 3
Joined: Wed Jul 12, 2006 10:53 am

Post by arachaz »

I never used curl before. Can you explain how.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have a read through the manual. If you have further, more specific, questions on its usage, please post back.
Post Reply