scrape and display on the fly ???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

scrape and display on the fly ???

Post by wesnoel »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Well I have been searching for this all night to no avail. 

What I am looking for is the ability to scrape the first 25 user images on the myspace browse page here: [url]http://browseusers.myspace.com/Browse/Browse.aspx?z=1[/url] and then display them along with a link back to the user profile myspace. 
If I get pointed in the right direction I might be able to hack my way through some code snippets if anyone wants to offer some up.

No DB or anything just on the fly scraping if possible.


[b]This is one image[/b]
[syntax="html"]
<div id="ctl00_cpMain_Browse_skin_ResultsView_browseList_ctl03_photoNameOnlyItemView" class="alignC">
			
				<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=283903034" id="ctl00_cpMain_Browse_skin_ResultsView_browseList_ctl03_pnDisplayName">jenny</a>
				<br>
				<a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=283903034" id="ctl00_cpMain_Browse_skin_ResultsView_browseList_ctl03_pnImg">
					 <img src="http://a232.ac-images.myspacecdn.com/images01/22/s_9b5317894443f786b8ee898d25b4394f.jpg" id="ctl00_cpMain_Browse_skin_ResultsView_browseList_ctl03_pnImgTag"></a>
				<br>
				

<br>
				<br>
		  
		</div>


Cheers and thank to anyone that can help.

Wes/


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post by Jonah Bron »

Okay, correct me if I'm wrong, but I think this is what you are looking for:

get the contents of the file
regex out the image
echo the image

Code: Select all

$pics = file_get_contents('http://browseusers.myspace.com/Browse/Browse.aspx?z=1');
preg_match(/(<img src="http:\/\/a232.ac-images.myspacecdn.com\/[^"]" id="ctl00_cpMain_Browser_skin_ResultsView_browseList_ctl03_pnImgTag">){25}/, $matches, $pics);
print_r($matches);
you will have to set the php.ini file to treat absolute paths as files.
Post Reply