How do I CURL www.google.com - it keeps redirecting me to .co.uk

前端 未结 7 2516
南笙
南笙 2021-02-19 16:06

I am using CURL to check for the existence of a URL (HEAD request) but when I test it with www.google.com, it redirects me to www.google.co.uk - probab

相关标签:
7条回答
  • 2021-02-19 16:46

    Another option is to use simply encrypted.google.com. That won't redirect.

    0 讨论(0)
  • Try accessing www.google.com/ncr, it'll avoid the redirect to the .co.uk (or any other national) page.

    0 讨论(0)
  • 2021-02-19 16:49

    You should turn off the follow location from curl (set it to false) and you won't be redirected anymore ...

       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    
    0 讨论(0)
  • 2021-02-19 16:52

    You could use www.google.co.uk directly, no difference there. google.com/.net always redirect to your location but if you use a country TLD like .co.uk it will not redirect.

    There is no way (known to me) to prevent the redirect when using .com or .net.

    0 讨论(0)
  • 2021-02-19 16:54

    You need to use curl with a cookie that simulate a similar behavior in a browser.

    When you visit google.com from England it redirects you to google.co.uk, however there is a link on that page titled "go to google.com" that lets you go back to google.com and stay there. It uses a cookie to remember your site preferences.

    For example, here are the cookies that I have after doing this (using firefox):

    alt text

    0 讨论(0)
  • 2021-02-19 16:57

    A bit of a hack, but how about using an IP address? http://216.239.59.147/ http://66.102.7.104/

    0 讨论(0)
提交回复
热议问题