I want to scrappe data from fiverr.com i write php code : But its not returing data. I also tried with curl as well. No success at all. <?php $url ='https://www.fiverr.com/gigs/gigs_as_json?host=search&type=single_query&query_string=pet&search_filter=rating&category_id=3&sub_category_id=49&limit=48'; $html = file_get_contents( $url); echo $html; ?>
I believe the problem may be - fivver.com sets some cookies and then tells you to send another request to the same URL with your new set of cookies. PHP's file_get_contents() Code (markup): will not send cookies by default and will put you into a 302 redirect loop. i would manually manage the cookies something like; $url = 'http://www.fiverr.com/gigs/gigs_as_json?host=search&type=single_query&query_string=pet&search_filter=rating&category_id=3&sub_category_id=49&limit=48'; $opts = array('http' => array( 'header' => 'Cookie: locale=en%3B0%3Bfalse; suggested_locale=1;', )); $ctx = stream_context_create($opts); $data = file_get_contents($url, false, $ctx); Code (markup): the variable $data contains binary data since the site gzipped the contnet. so you may want to have plain data. $data = gzedecode($data); Code (markup): Now you will have JSON encoded data that you can parse using json_decode() Code (markup): hope this helps.
jQuery $.ajax({ url:'proxy.php', type:'POST', data:{ address:'http://www.google.com'}, success:function(response){ alert(response); }}); PHP (proxy.php) echo file_get_contents($_POST['address']);