How to display a webpage from another domain in our php page

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

How to display a webpage from another domain in our php page

Post by krieya »

Hi,

I just started learning PHP.

I am trying to display a webpage from other domain (eg: www.google.com) in my PHP page.

I tried "include" function, page is getting loaded however,
Due to the change in absolute path, no functionality is working.
Example: if we search for a string and click on search button, Page Not Found 404 error is getting displayed.

Is there any php function that is equivalent to <iframe> ? So that page gets loaded as it is.

Please suggest me.

Thanks!!
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: How to display a webpage from another domain in our php

Post by Jonah Bron »

Why do you want to do this? Without some major work, you really can't fix all the relative paths. How about just using an <iframe>?
krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

Re: How to display a webpage from another domain in our php

Post by krieya »

If I use Iframe, I am facing cross domain issues.

All that I want to do is, set and get the attributes of an HTML element of a web page from other domain (eg: set value of text field, get value of text field, click button etc)

I know that solution can be derived using browser add ons however it will become a browser specific.

Hence I am trying to get this done using some javascript or some thing stuff like it.

Please suggest the best solution for my problem.

Thanks!
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: How to display a webpage from another domain in our php

Post by Jonah Bron »

Maybe I could help more if I knew exactly what you were trying to do. Could you explain in more detail?
krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

Re: How to display a webpage from another domain in our php

Post by krieya »

Actually, I am trying to develop a webpage that can assist our daily and routine tasks.

Example:
If we want to login to yahoomail.
First I will create the script to this tasks.
Script looks like: window.location('http://yahoomail.com');document.getElementId(<id of login text field>).value="user name";document.getElementId(<id of password text field>).value="password";document.getElementId(<id of login button>).click

So I want to load yahoomail.com in my webpage and then run the above script to get me login into my yahoo mail.

Please let me know if there is any possibility in doing the above task.

Thanks!!
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: How to display a webpage from another domain in our php

Post by Jonah Bron »

Unfortunately, doing that would be very difficult. The effort required would far exceed the trouble of just logging in. Plus it's insecure.
krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

Re: How to display a webpage from another domain in our php

Post by krieya »

Yes, I am slowly understanding that it is very difficult.

Also I have tried browser addons which is the best solution for this however at workplace we should have admin rights to get the addon installed (eg: IMacros addon will get our job done).

However I was just searching with a hope, Is there a way to do this?

Please suggest me If you have any solutions though it is very difficult.

Thanks!!
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: How to display a webpage from another domain in our php

Post by Jonah Bron »

Why can't you just visit the login page and tell your browser to save the password? I can do it it about 5 seconds flat.
krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

Re: How to display a webpage from another domain in our php

Post by krieya »

Yes for login I can do in that way however I am looking at a larger picture.
I want to set and get the attributes of the HTML DOM (like click button, select radio button, set text field etc) which inturn assist daily routine tasks of a web application tester.

Any suggestions on how to access DOM inside IFrame? or any other way to access DOM from other domain?

Thanks!!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to display a webpage from another domain in our php

Post by VladSun »

You may try building a cURL proxy scripts. Cross domain issues will be solved.
http://php.net/manual/en/book.curl.php

And you can put and use the login credentials outside the page because the actual login is performed by your PHP script (i.e. server side).
There are 10 types of people in this world, those who understand binary and those who don't
krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

Re: How to display a webpage from another domain in our php

Post by krieya »

So Using this Client URL Library.

Can we click on buttons, set text field values, select radio buttons?

I am looking to assist the tasks of a web application manual tester which always have routine tasks and static inputs.
(like filling data in text fields, selecting radio buttons, dropdowns, clicking links, buttons etc)

Thanks!!
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: How to display a webpage from another domain in our php

Post by matthijs »

And what about normal (old style) frames? You can include complete websites that way.

However, I still don't understand the purpose exactly. Are you building a dashboard kind of webpage?

Not sure which websites you're talking about, but most webservices do have some kind of API, which allow you to to things. Like with twitter, there are ways to show the latest tweets in your webpage etc
krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

Re: How to display a webpage from another domain in our php

Post by krieya »

For a web application manual tester, there are many routine tasks and have static inputs for that.

Eg: For one of our application to verify the result a manual tester need to navigate through 10 pages filling more than 15 fields on each page which is routine and having static input fields, this task takes more than 45 mins however if we automate this process we can get this done in less than 5 mins.

So I am trying to develop a web page which will perform the tasks like,
Select radio button, set text in text field, click button etc.

So I am doing some R&D to get this job done.

Also I have tried browser addons which is the best solution for this however at workplace we should have admin rights for all the manual tester to get this installed (eg: IMacros addon will get our job done).

Please suggest a way to get this job done.

Thanks!!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to display a webpage from another domain in our php

Post by VladSun »

krieya wrote:So Using this Client URL Library.

Can we click on buttons, set text field values, select radio buttons?

I am looking to assist the tasks of a web application manual tester which always have routine tasks and static inputs.
(like filling data in text fields, selecting radio buttons, dropdowns, clicking links, buttons etc)

Thanks!!
Better use http://watir.com/
There are 10 types of people in this world, those who understand binary and those who don't
krieya
Forum Newbie
Posts: 14
Joined: Sat Mar 05, 2011 12:45 am

Re: How to display a webpage from another domain in our php

Post by krieya »

To use "watir", first I have to install it in my browser which inturn need administrator access at my workplace.

This is the one of the reason why I want to develop a web page that accomodates the user to automate their task with out any installation.

Actually, we have so many addons to do these tasks (imacro, GreaseMonkey etc) however all of these need Installation.

However I am looking for a solution that do not need any installation.

Hence I am doing this R&D to develop a webpage to which user can directly go and write his scripts and execute them with out installing any thing.

I felt that it can be done if we can change the DOM in our browser using javascript or any other stuff however to access the DOM from other domain is causing cross domain issues.

Do I have any way to get this work done?

Thanks!!
Post Reply