Site returning a different page when accessed by php

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 17
Joined: Sun Apr 01, 2012 11:52 pm

Sun May 13, 2012 2:32 am

I have to parse this page:

if it is normally accessed by a browser, it returns the correct contents, but if I try to parse it with:
@file_get_html($url) or file_get_html
it returns a totally different content that looks like a default page. What might they have inserted in the page to protect it, if that is the case, and how may I overcome it?
This is a page of mine that tries to do the trick printing the (correct)url and the (wrong) result content: ... inea=52732

Thanks, Fabrizio
User avatar
php-forum GURU
php-forum GURU
Posts: 236
Joined: Sat Apr 14, 2012 11:57 am
Location: Vilnius, Lithuania

Sat May 19, 2012 3:23 am

You might need to set user-agent, that way you you would 'fake' a browser

Code: Select all

$url = "";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_USERAGENT, "Let me pass you idiot");
$content = curl_exec($curl);
echo $content;
Post Reply