duanmu1736 2019-05-10 03:33
浏览 185

在request-php中设置位置

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置