-1

How do I get the HTML code of another site it wants cookies to be enabled? I just need to parse this page www.fx-trend.com/pamm/rating/

I'm using javascript jquery (jQMobile) and sometimes PHP.(I prefer to use js)

here is a sample with PHP:

<?php
$url = 'url';
$html = file_get_html($url);
//$html = file_get_contents($url);
echo $html;
?>

here is a sample with js: How to get data with JavaScript from another server?

OR

$(this).load(url);
alert($(this)); //returns object Object

server answer:

Cookies must be enabled in your browser! Try to clear all cookies, if cookies are enabled.

code samples are welcome.

1 Answers1

2

Try using Curl and enable cookies. The code sample below is snagged from this page.

<?php
/* STEP 1. let’s create a cookie file */
$ckfile = tempnam ("/tmp", "CURLCOOKIE");

/* STEP 2. visit the homepage to set the cookie properly */
$ch = curl_init ("url");
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$output = curl_exec ($ch);

var_dump($output);

Edit: You might have to fake a browser by changing the default user agent header.

Markus Hedlund
  • 23,374
  • 22
  • 80
  • 109