Jump to content

How do I write script to parse a Myspace webpage?


supratwinturbo

Recommended Posts

Hi all,

      Can someone please point me in the right direction? I have been trying to figure out how people can grab the layout from a myspace page by using the friendid. I think they simply parse the myspace page for anything between <style> ... </style> and then send the code to a form. For example, this is one site that offers the feature:

http://pimpyours.com/myspace_theme_stealer/index.php

Here is an example friendid 31323350

Anyone have any ideas? Has someone written something similar? Your help is much appreciated.

Thank you,

SupraTT
  • 4 months later...
[code]<?php

function textbetweenarray($s1,$s2,$s){
  $myarray=array();
  $s1=strtolower($s1);
  $s2=strtolower($s2);
  $L1=strlen($s1);
  $L2=strlen($s2);
  $scheck=strtolower($s);

  do{
  $pos1 = strpos($scheck,$s1);
  if($pos1!==false){
$pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
if($pos2!==false){
  $myarray[]=substr($s,$pos1+$L1,$pos2);
  $s=substr($s,$pos1+$L1+$pos2+$L2);
  $scheck=strtolower($s);
  }
}
  } while (($pos1!==false)and($pos2!==false));
return $myarray;
}

$friendid = $_GET['id'];

$url = "http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=$friendid";

$file = file_get_contents($url);

$style = textbetweenarray("<style type=\"text/css\">", "</style>", $file);

echo "<pre>";

foreach($style as $css) {
echo "$css\n\n";
}

echo "</pre>";

?>[/code]

Not tested, should work fine leaving you with an array of each occurrence of text between <style type="text/css"> and </style>. Can be adapted to suit your needs easily.

Chigley :)
  • 3 months later...

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.