Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Including webpages but exluding selected content
Old 10-25-2008, 11:53 PM Including webpages but exluding selected content
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Hey,

I was wondering if it was possible to <?php include('page.php'); ?>
Now on the persons site he has menus etc, I was wondering if I would be able to include his webpage onto my site as an example but remove the menus he has.

All his content is contained within his website as <div> tags.
Is it possible to not display his <div class="menu"> </div> ??
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 10-25-2008 at 11:54 PM..
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-26-2008, 12:19 AM Re: Including webpages but exluding selected content
Mark Henderson's Avatar
Extreme Talker

Posts: 207
Name: Mark Henderson
Location: Yorkshire
Trades: 0
Do you have the guys permission to do that? just move the file locally and remove the bits you dont want manually.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
- Affordable Web/Graphics Design -
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
ify - WHOIS Lookup, reverse IP, traceroute and more!
Mark Henderson is offline
Reply With Quote
View Public Profile Visit Mark Henderson's homepage!
 
Old 10-26-2008, 12:55 AM Re: Including webpages but exluding selected content
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
I dont think that would work because his page accesses database information.
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 10-26-2008, 11:05 PM Re: Including webpages but exluding selected content
Experienced Talker

Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
Trades: 0
You could strip the menus' etc using regular expressions.
I'll add a function to strip <img> -tags for you, the rest you can find from www.php.net

PHP Code:
$dataURL "http://site.you.want/fullurl.php";
$result file_get_contents($dataURL);
function 
strip(&$variable){
    
//REGEXP TO STRIP ALL TAGS THAT START WITH <img...
    
return eregi_replace("< *img[^>]* *>"""$variable);
}
// USAGE AS FOLLOWS
$result strip($result);
echo (
$result); 
jabis is offline
Reply With Quote
View Public Profile Visit jabis's homepage!
 
Old 10-27-2008, 07:18 PM Re: Including webpages but exluding selected content
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Hey, thanks for the point in the right direction.
I managed to get rid of all the images etc by using
PHP Code:
<?

$dataURL 
"friendssite";
$result file_get_contents($dataURL);
function 
strip($result){
    
//REGEXP TO STRIP ALL TAGS THAT START WITH <img...
    
return eregi_replace('(.jpg|.gif|.png)'""$result);

}
// USAGE AS FOLLOWS
$include strip($result);
echo (
$include);
?>
I know this is very sloppy because all it does is cut out the end of the code. It still leaves <img src="image"> but I found that it wasnt removing the background images.

Is there a way to replace multiple values?
eg
PHP Code:
return eregi_replace("< *img[^>]* *>"""$variable);
return 
eregi_replace("< *background[^>]* *>"""$variable); 
This wouldnt work because of the $variable being used twice, but I'm not sure how to stick it all together at the other end if I used more than one variable.

Thanks for your help, has taught me about eregi_replace
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 10-27-2008 at 07:20 PM.. Reason: Values, Variables
lothop is offline
Reply With Quote
View Public Profile
 
Old 10-27-2008, 07:32 PM Re: Including webpages but exluding selected content
Experienced Talker

Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
Trades: 0
Quote:
Originally Posted by lothop View Post
Hey, thanks for the point in the right direction.
I managed to get rid of all the images etc by using
PHP Code:
<?

$dataURL 
"friendssite";
$result file_get_contents($dataURL);
function 
strip($result){
    
//REGEXP TO STRIP ALL TAGS THAT START WITH <img...
    
return eregi_replace('(.jpg|.gif|.png)'""$result);

}
// USAGE AS FOLLOWS
$include strip($result);
echo (
$include);
?>
I know this is very sloppy because all it does is cut out the end of the code. It still leaves <img src="image"> but I found that it wasnt removing the background images.

Is there a way to replace multiple values?
eg
PHP Code:
return eregi_replace("< *img[^>]* *>"""$variable);
return 
eregi_replace("< *background[^>]* *>"""$variable); 
This wouldnt work because of the $variable being used twice, but I'm not sure how to stick it all together at the other end if I used more than one variable.

Thanks for your help, has taught me about eregi_replace
You can't have multiple returns in a function, but instead you could do

PHP Code:
$variable eregi_replace("< *img[^>]* *>"""$variable);
$variable eregi_replace("< *background[^>]* *>"""$variable);
return 
$variable
As I said earlier, go to php.net and check the eregi_replace from the search option in functions list, there're usually a lot comments on other developers, who've used certain functions and post their solutions there. It's the best place to get a hang on php regexps Other solutions would be to google on php regexp functions Just try it out, you'll be amazed how much valid stuff you can get your hands on with a little effort

PS. I didn't look at your regex, if it's valid in any case, but by the looks of it, it's matching every tag containing background and ending at the closing tags end... Just go digg around some regex cheat sheets or something, to see the full potential

Last edited by jabis; 10-27-2008 at 07:36 PM.. Reason: a little addition
jabis is offline
Reply With Quote
View Public Profile Visit jabis's homepage!
 
Old 10-27-2008, 08:13 PM Re: Including webpages but exluding selected content
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Quote:
As I said earlier, go to php.net and check the eregi_replace from the search option in functions list
That was exactly what I did
I just wasnt sure on returning the information back.

Thanks for your help.
Giving people a push in the right direction definately helps them learn rather than giving them the code saying put this in your page and it will work. They wont learn much.

Took me about an hour to understand how eregi_replace works and in the process found str_replace, but now that I've gotten my head around it, wont be asking the same question twice. (hopefully)

I don't have time to update my work yet, as I have work, but ill be back to post what happens so anyone following this can see the outcome
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 10-27-2008 at 08:15 PM.. Reason: I need more time in each day ><
lothop is offline
Reply With Quote
View Public Profile
 
Old 06-15-2010, 09:09 AM Re: Including webpages but exluding selected content
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
It's been a while, but trying to do a similar kind of thing.

I was wondering how I could identify a bit of text, and then output it.
So say theres a news article that gets updated regularly, and I want that displayed on a section of my site.
How would I isolate that section of code?

Cheers
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Including webpages but exluding selected content
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27614 seconds with 12 queries