Loryman Posted May 27, 2007 Share Posted May 27, 2007 Hey, Im rather new with PHP and I was just wondering how it would be possible to scrape the Display name of a myspace.com user? What I'm after is a form that, when given a User ID from myspace, it will search their page and find out their display name is, and then display it. My friend has written me a code to find out the default image of a user and that seems to work perfectly. This is what he gave me. index.php <form method="post" action="index2.php"> Enter Your Friend ID To Continue:<br> <input name="friendid" id="friendid" maxLength="10"><br> <input type="submit" value="Login"> </form> index2.php <?php $friendid= $_POST['friendid']; //member id $url="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=$friendid"; $t = join("",file("$url")); $picid = '/ctl00_Main_ctl00_UserBasicInformation1_hlDefaultImage" .*?"><img src="(.*?)"/'; $t = ereg_replace("\n", "", $t); preg_match_all($picid, $t, $m); $img=$m[1][0]; echo "<img src='$img'>"; ?> I've tried altering bits and pieces of the code myself, and so far i've failed every time. All I know is the Display name is in this code. Quote: <span class="nametext">Display Name Goes Here</span> Can someone help me alter this code so it will find out BOTH the display name, and default image of a user? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/53157-scraping-from-a-website/ Share on other sites More sharing options...
MadTechie Posted May 27, 2007 Share Posted May 27, 2007 here's a nice start <?php preg_match_all('%<span class="nametext">(.*)</span>%im', $t, $m, PREG_PATTERN_ORDER); $m= $m[0]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/53157-scraping-from-a-website/#findComment-262609 Share on other sites More sharing options...
Loryman Posted May 27, 2007 Author Share Posted May 27, 2007 I'm not entirely sure where to put that code as its my friends code I'm altering, and he's only left me with one comment to read, so im not sure what the rest is about. I'm testing the code out as we speak here. I'm using the friend ID: 6221 as an example. Quote Link to comment https://forums.phpfreaks.com/topic/53157-scraping-from-a-website/#findComment-262635 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.