How to set browser language when using curl to extract content?

It uses curl in php to retrieve content from an external website. I get content from websites like https://www.flickr.com/ . In different languages, the language will be displayed in different languages ​​(in different languages). I want to get only English content. I tried:

  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12");

But that will not work. Instead, it extracts Chinese content. Any tips?

+4
source share
1 answer

Set the Accept-Languagerequest header using CURLOPT_HTTPHEADER, for example:

curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept-Language: en']);
+5
source

Source: https://habr.com/ru/post/1543824/


All Articles