str_replace stuff

This is a discussion on str_replace stuff within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi all! I'm trying to grab content from my myspace profile with php and fopen. I just want the ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-23-2006
Michael
 
Posts: n/a
Default str_replace stuff

Hi all!

I'm trying to grab content from my myspace profile with php and fopen. I
just want the url of my friends profile and the url of their myspace
thumbnail so i can load them into flash as a variable. example string output
desired:
&friend1=http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=495 8197&image1=http://myspace-668.vo.llnwd.net/00102/86/66/102536668_s.jpg

so far my progress: http://serverspeed.com/grabmyspace.php

this is the code I have so far:

<?php
$URL =
'http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=441 6517';
// my profile
$Start = ' <table width="435" border="0" cellspacing="0"
cellpadding="5" align="center">';
$GrabEnd = ' </table>';

$file = fopen("$URL", "r");

$r = file_get_contents($URL);

$stuff = eregi("$Start(.*)$GrabEnd", $r, $content);

fclose($file);


$content = str_replace('<tr>', '', $content);
$content = str_replace('<td bgcolor="FFFFFF" align="center" valign="top"
width="1">', '', $content);
$content = str_replace('<table border="0" cellspacing="0" align="center">',
'', $content);
$content = str_replace('<td bgcolor="FFFFFF" align="center" valign="top"
width="107" style="word-wrap:break-word">', '', $content);
$content = str_replace('<table border="0" cellspacing="0" align="center">',
'', $content);
$content = str_replace('&nbsp;<a href="', '&link1=', $content);
$content = str_replace('</a>&nbsp;', '', $content);
$content = str_replace('</td>', '', $content);
$content = str_replace('</tr>', '', $content);
$content = str_replace('<td bgcolor="FFFFFF" align="center" valign="top"
width="25%"><a href="', '', $content);
$content = str_replace('<td bgcolor="FFFFFF" align="center" valign="top"
width="25%"><a
href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=',
'', $content);
$content = str_replace('<img src="', '&img1=', $content);
$content = str_replace('"></a><br>', '', $content);
$content = str_replace('<DIV style="width:80px;height:20px;" ID="', '',
$content);

$content = str_replace('</div>', '', $content);
$content = str_replace('</table>', '', $content);


echo $content[1];

?>

I appreciate any help on this. I'm getting better at programming but I still
get in over my head from time to time.


Reply With Quote
  #2 (permalink)  
Old 06-24-2006
Janwillem Borleffs
 
Posts: n/a
Default Re: str_replace stuff

Michael wrote:
> I appreciate any help on this. I'm getting better at programming but
> I still get in over my head from time to time.
>


Remember that less = more; to get all thumbnail links, simply do:

$base = 'http://profile.myspace.com';
$path = '/index.cfm?fuseaction=user.viewprofile&friendid=441 6517';
$pattern = '|(http://myspace-\d+.vo.llnwd.net/[\d/]+_s.jpg)|';

$contents = file_get_contents("$base$path");
preg_match_all($pattern, $contents, $matches);

print_r($matches);


JW


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:58 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0