Posted 12 years ago
·
Author
right guys here is what i was able to come up with its not done 100% but thought some of you would like to see where im at
note make sure to edit this line
replace uruserid with your user id i havent had a chance to test this yet but it should work ill be writing a way to disply it 2mor and also the db stuct for it
<?php
function get_date_time($timestamp = 0)
{
if ($timestamp)
return date("Y-m-d H:i:s", $timestamp);
else
return gmdate("Y-m-d H:i:s");
}
class IMVU
{
private $contents = null;
public function __construct()
{
$curl = curl::getInstance();
try {
$curl->setopt_array(array(
CURLOPT_URL => 'http://www.imvu.com/catalog/web_mypage.php?user=uruserid&preview=1',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
CURLOPT_REFERER => 'http://www.google.com/',
CURLOPT_TIMEOUT => '10'
));
$this->contents = $curl->exec();
} catch (Exception $e) {
die($e->getMessage());
}
}
public function scrape()
{
preg_match_all('/<table width="100%" border="0" cellspacing="0" cellpadding="0" id="aboutme_panel_body">/(.*?)<\/table>/si', $this->contents, $matches);
if (count($matches[0]) == 1) {
for ($i = 0; $i <= 1; $i++) {
if (preg_match('|<b><span class="notranslate">(.*)</span></b>|U', $matches[0][$i], $nick)) {
preg_match('/<font size="-1">Avatar since: <span class="notranslate">(.*)<\/span>/si', $matches[0][$i], $since);
preg_match('|<i id="user_tagline"><span class="notranslate">(.*)</span>|U', $matches[0][$i], $tagline);
preg_match_all('|<img width="160" height="220" src="(.*)"|U', $matches[0][$i], $image);
$pic = (string)$image[1][0];
mysql_query("INSERT INTO `imvu` (`tagline`, `since`, `nick`)
VALUES ('" . $tagline . "', '" . $since . "', '" . $nick . "')");
if (!file_put_contents('imvu/pics/' . $nick . '.jpg', file_get_contents($pic))) {
throw new Exception('Couldn\'t write to imvu/pics directory.');
}
}
}
}
}
}
note make sure to edit this line
replace uruserid with your user id i havent had a chance to test this yet but it should work ill be writing a way to disply it 2mor and also the db stuct for it