Jump to content

Getting information from other sites


Muncey

Recommended Posts

Hi, was planning on making a bbcode and i wanted to know how to get data from a site. For example a site displays information about albums.

 

Link example: albumsite.com/albumname/

 

Each album has it's own page but all the pages are layed out the same... for example:

 

Artist: Name here

Album Title: Title here

Year: Year here

 

ect.

 

How do i pull the data out of artist/album title ect depending on what is put inbetween the bbcode.

 

[album]albumname[/album]

 

Hope that makes sense, Thanks in advanace.

Link to comment
https://forums.phpfreaks.com/topic/108063-getting-information-from-other-sites/
Share on other sites

Pull the data from another site.

 

So when [album]____[/album] is put in the part inbetween the album brackets is taken and put into the url and then it takes the relevant data from the url.

 

EG.

 

[album]RandomName[/album]

 

Would get data from www.albumsite.com/RandomName/

 

and it would then take the information from there.

Both lol, you use the info between the bbcode. For example...

 

[bbcode]test[/bbcode]

 

Then $a = "www.randomsite.com/ ".$x

 

Where $x = the data between the bbcode.. in this case it would be test.

 

After that you take $a and gather the information from the url. So you'd find "Title:" and get the information after that...

Ok, well to get the info between is easy (only because I also just made a bbcode parser :D).

 

<?php
$text = "[album]name[/album]";
$i = 0;
preg_match_all("/\[album\](.+)\[\/album\]/U", $text, $matches);
while($matches[0][$i]!='') {
echo $matches[1][$i];
$i++;
}

 

And for the gathering info look at the php manual file_get_contents.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.