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
Link to comment
Share on other sites

  • 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 :)
Link to comment
Share on other sites

  • 3 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.