0

I have a link to an app on Apple App Store. I need to use its data on my own webpage. To be more precise, I want to extract the app icon, its category and whether or not it is free and to add this data to my webpage. How can I do this using JavaScript?

9
  • You can't, you should use a serverside language for scraping like this. Commented Mar 31, 2013 at 20:02
  • And how would I do this using PHP? Commented Mar 31, 2013 at 20:03
  • Are you talking about client-side or server-side JavaScript? If client-side: that probably won't work. Commented Mar 31, 2013 at 20:04
  • @AnđelijaAnđelić Surely you can search for "PHP scraping" now. (Something like Simple HTML DOM should do the job.) Commented Mar 31, 2013 at 20:04
  • 1
    Anything is possible! Using ajax with a Yahoo Pipe or YQL, or using node.js on the serverside would make this possible with javascript, it just does'nt makes sense when it's so easy to do on the serverside. I'd use cURL, but all you really have to do in PHP to get an external page is file_get_content('http://mysite.com/page.php'), and then you'll have to parse that to get what you want. Commented Mar 31, 2013 at 20:16

2 Answers 2

1

To my knowledge, you can't do this using Javascript due to Cross Platform security issues. You would nee a Web Server and possibly write a scraper in PHP to read that page. then call your PHP script from your JavaScript.

Sign up to request clarification or add additional context in comments.

Comments

0

Here is the PHP Script:

<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_REFERER, "https://itunes.apple.com/us/app/google+/id447119634?mt=8"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozzila/1.0"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); $logo = explode('<div class="artwork">', $output); $logo = explode('src="', $logo[1]); $logo = explode('"', $logo[1]); $logo = $logo[0]; $category = explode('<span class="label">Category:', $output); $category = explode('">', $category[1]); $category = explode('<', $category[1]); $category = $category[0]; echo $logo; echo $category; ?> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.