Skip to content

Instantly share code, notes, and snippets.

@vnorby
Created August 9, 2010 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnorby/515976 to your computer and use it in GitHub Desktop.
Save vnorby/515976 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tattle.com</title>
</head>
<style>
textarea {
width: 100%;
height: 700px;
overflow: auto;
font-family: monospace;
}
small a
{
color: #999;
}
</style>
<body>
<div id="container">
<form action="index.php" method="post">
Enter iTunes Keyword: <input type="text" name="keyword" value="<?PHP echo $_POST["keyword"] ?>" /> <input type="submit" name="submit" value="Go" />
</form>
<p>
<?PHP
function getStringSection($message, $begin, $end) { //Return a section of a string going forwards through $message, starting at $begin, and ending at $end
$begin_chars = strlen($begin);
$section_begin = stripos($message, $begin) + $begin_chars;
$section_end = stripos($message, $end, $section_begin);
$section_length = $section_end - $section_begin;
$section = substr($message, $section_begin, $section_length);
return $section;
}
if($_POST["submit"]) {
ini_set('user_agent', 'iTunes/9.0.3 (Windows; Microsoft Windows XP Professional Service Pack 3 (Build 2600)) AppleWebKit/531.22.7');
$page = file_get_contents("http://ax.search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?submit=seeAllLockups&restrict=true&entity=software&term=" . $_POST["keyword"] . "&media=all
");
preg_match_all( "/\<GotoURL(.*?)\>/", $page, $details);
echo "<ol>";
for($i = 0; $i < (count($details[1]) - 2); $i = $i + 3)
{
echo "<li><a href=\"" . getStringSection($details[1][$i], "url=\"", "\"") . "\">" . getStringSection($details[1][$i], "draggingName=\"", "\"") . "</a><small> by <a href=\"" . getStringSection($details[1][$i], "url=\"", "\"") . "\">" . getStringSection($details[1][$i + 2], "draggingName=\"", "\"") . "</a></small></li>";
}
echo "</ul>";
//echo "<xmp>" . preg_replace('/\s\s+/', '', $page) . "</xmp>";
}
?>
</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment