在request-php中设置位置

我正在运行一个从amazon.ae获取数据的应用程序。 我使用下面的代码。</ p>

 &lt;?php 
$ link ='https://www.amazon.ae/Huawei-P20-Pro-Dual-SIM/ dp / B07MMQRNYT / ref = sr_1_3?keywords = huawei&amp; qid = 1557457063&amp; s = electronics&amp; sr = 1-3';
$ opts = array(
'http'=&gt; array(
'method'= &gt;“GET”,
'header'=&gt;“Accept-language:en

”。
“Cookie:foo = bar

”。
“用户代理:Mozilla / 5.0 (X11; Linux x86_64)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 51.0.2704.103 Safari / 537.36


//'ignore_errors'=&gt; true

);
$ context = stream_context_create($ opts);
$ html = file_get_contents($ link,false,$ context);
echo $ html;
?&gt;
</ code> </ pre>

我的服务器位于美国。 因此,应用程序打开页面就像从美国浏览一样。 此代码显示Amazon.ae页面,如下所示</ p>

< img src =“https://i.stack.imgur.com/lPiQm.png”alt =“从美国打开”> </ p>

问题是 - 这不是 如果用户从阿联酋打开相同的URL,页面将如何显示。 如果从阿联酋打开,页面显示如下。</ p>

</ p>

您可以看到' 两个地方的价格'和'售'是不同的。</ p>

我想要的是获取页面,好像我的应用程序是从阿联酋运行的。
如何制作我的应用程序 从阿联酋而不是美国运行代码。
谢谢提前</ p>
</ div>

展开原文

原文

I am running an application which fetches data from amazon.ae. I use the code below.

<?php
    $link = 'https://www.amazon.ae/Huawei-P20-Pro-Dual-SIM/dp/B07MMQRNYT/ref=sr_1_3?keywords=huawei&qid=1557457063&s=electronics&sr=1-3';
    $opts = array(
        'http'=>array(
            'method'=>"GET",
            'header'=>"Accept-language: en
" .
                  "Cookie: foo=bar
" . 
                  "User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
"
        // 'ignore_errors' => true
        )
    );
    $context = stream_context_create($opts);
    $html = file_get_contents($link, false, $context);
    echo $html;
?>

My server is located in the USA. So the application opens the page as if it is browsing from the USA. This code displays the Amazon.ae page as below

Opened from US

The problem is - this is not how the page is displayed if a user opens the same URL from UAE. The page is displayed as below if opened from UAE.

enter image description here

You can see the 'price' and 'sold by' is different for both locations.

What I want to do is to fetch the page as if my application is running from UAE. How do I make my application run the code from UAE instead of US. Thanks in advance

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问