Art
Art

Reputation: 11

@file_get_contents() and curl failed to get page contents, I need alternate code

some sites are blocking @file_get_contents and the curl code also. I need code(PHP) that circumvents that problem. I only need to get the page contents so I can extract the title.

Upvotes: 0

Views: 912

Answers (1)

Alex Howansky
Alex Howansky

Reputation: 53573

You probably need to set the user agent string to emulate a "real" browser:

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20110319 Firefox/4.0');

Upvotes: 1

Related Questions