/    Sign up×
Community /Pin to ProfileBookmark

Get complete external HTML source

So that I can display external website on my page. Is it possible with PHP? I try to do it but I failed ?

to post a comment
PHP

16 Comments(s)

Copy linkTweet thisAlerts:
@Ben_RogersNov 26.2004 — Have you tried the [url=http://us2.php.net/file]file[/url] function?
Copy linkTweet thisAlerts:
@tanfwcauthorNov 26.2004 — Thank you. It's work. Learning date by date with the help of you people.
Copy linkTweet thisAlerts:
@Ben_RogersNov 26.2004 — [i]Originally posted by tanfwc [/i]

[B]Thank you. It's work. Learning date by date with the help of you people. [/B][/QUOTE]
You're welcome, and good luck.
Copy linkTweet thisAlerts:
@tanfwcauthorNov 27.2004 — any hint for grabing external code that is needed only?
Copy linkTweet thisAlerts:
@Ben_RogersNov 27.2004 — [i]Originally posted by tanfwc [/i]

[B]any hint for grabing external code that is needed only? [/B][/QUOTE]
I don't understand what you're asking for, could you be more specific?
Copy linkTweet thisAlerts:
@tanfwcauthorNov 27.2004 — [i]Originally posted by Ben R. [/i]

[B]I don't understand what you're asking for, could you be more specific? [/B][/QUOTE]


Let said I want only a specific part of the code and the code is dymanic. How do I ensure that I get the section of the code only?
Copy linkTweet thisAlerts:
@Ben_RogersNov 27.2004 — Well, what file() gets is what is sent to the client- it cannot get server side scripting, if that's what you mean...
Copy linkTweet thisAlerts:
@tanfwcauthorNov 27.2004 — [i]Originally posted by Ben R. [/i]

[B]Well, what file() gets is what is sent to the client- it cannot get server side scripting, if that's what you mean... [/B][/QUOTE]


Ok. Can I get the code and modify it on my side then display out?
Copy linkTweet thisAlerts:
@Ben_RogersNov 27.2004 — Yes.

Let's say, for example, you wanted to get the contents of the sidebar of [url=http://www.ryanbrill.com]Ryan Brill[/url]'s site (Sorry, Pyro)...[code=php]<?php
// Get file contents into a string
$file = implode('', file('http://www.ryanbrill.com/'));
// Seperate string into array- [0] is before '<div id="subnav">', [1] is after.
$file = explode('<div id="subnav">', $file);
// Since $file is an array, and [1] == after '<div id="subnav">', split that part by </div>
$file = explode('</div>', $file[1]);
// Now you have all the content between <div id="subnav"> and </div> in a variable.
$file = $file[0];
?>[/code]
Does that give you any ideas of what to do?
Copy linkTweet thisAlerts:
@tanfwcauthorNov 27.2004 — One question, why must use implode ?
Copy linkTweet thisAlerts:
@Ben_RogersNov 27.2004 — [i]Originally posted by tanfwc [/i]

[B]One question, why must use implode ? [/B][/QUOTE]
file() returns an array- I don't know of a function like it that doesn't- and implode makes an array into a string.
Copy linkTweet thisAlerts:
@tanfwcauthorNov 27.2004 — [i]Originally posted by Ben R. [/i]

[B]file() returns an array- I don't know of a function like it that doesn't- and implode makes an array into a string. [/B][/QUOTE]


Oh that's mean must change it to string before we can make changes to it right?
Copy linkTweet thisAlerts:
@Ben_RogersNov 27.2004 — [i]Originally posted by tanfwc [/i]

[B]Oh that's mean must change it to string before we can make changes to it right? [/B][/QUOTE]
That's mean? I don't understand- do you want it to be a line by line array? ?
Copy linkTweet thisAlerts:
@tanfwcauthorNov 27.2004 — [i]Originally posted by Ben R. [/i]

[B]That's mean? I don't understand- do you want it to be a line by line array? ? [/B][/QUOTE]


This string work perfectly fine. What do I have to take note when coding this?
Copy linkTweet thisAlerts:
@jinkasNov 29.2004 — just for the record, file_get_contents($file) will read the contents of $file into a string...it's identical to (but faster than) using file() and implode() together
Copy linkTweet thisAlerts:
@Ben_RogersNov 29.2004 — [i]Originally posted by jinkas [/i]

[B]just for the record, file_get_contents($file) will read the contents of $file into a string...it's identical to (but faster than) using file() and implode() together [/B][/QUOTE]
*Looks at manual page for file_get_contents()* O_o Didn't know you could use it for external files, thought it didn't support 'em. Yes, that is the better function to use.
×

Success!

Help @tanfwc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...