Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6377217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:50:35+00:00 2026-05-25T01:50:35+00:00

I have written a PHP script based on a piece of code I’ve found

  • 0

I have written a PHP script based on a piece of code I’ve found using Google. It’s purpose is to check particular site’s position in Google, given a particular keyword. Firstly, it prepares an appropriate URL to query Google (something like: “http://www.google.com/search?q=the+keyword&ie=utf-8&oe=utf-8&num=50“), then it downloads the source of a site located at the URL prepared before. After that, it counts the position using regular expressions and the knowledge about what div’s classes does Google use for results.

The script works fine when the URL I want to download from is in the domain “google.com”. But since I it’s intended to check position for polish people, I would like it to use “google.pl”. I wouldn’t care, but the search results can really vary between the two (even more than 100 positions of difference). Unfortunately, when I try to use the “pl” domain, the cURL just doesnt’t return anything (it waits for the timeout first). However, when I ran my script on another server, it worked perfectly on both of “google.com” and “google.pl” domains. Do you have an idea why can something like this happen? Is there a possibility that my server was banned from querying the “google.pl” domain?

Here, my cURL code:

private function cURL($url)
{
    $ch = curl_init($url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
    return curl_exec($ch);
    curl_close($ch);  
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:50:36+00:00Added an answer on May 25, 2026 at 1:50 am

    First of all, I cannot reproduce your problem. I used the following 3 cURL commands to simulate your situation:

    curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.5 (KHTML, like Gecko) Version/5.1 Safari/534.51.3" http://www.google.com/search?q=the+keyword
    curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.5 (KHTML, like Gecko) Version/5.1 Safari/534.51.3" http://www.google.pl/search?q=the+keyword
    curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.5 (KHTML, like Gecko) Version/5.1 Safari/534.51.3" http://www.google.nl/search?q=the+keyword
    

    The first one is .com, because this should work as your reference point. Positive.
    The second one is .pl, because this is where you are encountering problems with. This also just works for me.
    The third one is .nl, because this is where I live (so basically what’s .pl for you). This too just works for me.


    I’m not sure, but this could be one possible explanation:

    • Google.com is international, when I enter something at google.nl for example, I still go to google.com/search?q=... (the only difference is the additional lang-param).
    • Since google.nl/search?q=... redirects to google.com (302). Its actual body is empty.
    • I don’t know, but it is possible cURL isn’t able to handle redirects, or you need to set an additional flag.

    If this is true (which I’ll check now), you need to use google.com as domain and add an additional lang-param, instead of using google.pl.

    The reason your other server does the trick, can be because cURL’s configuration varies, or the cURL version isn’t the same.


    Also, it’s blocking cURL’s default user-agent string, so I’ld also suggest you to change it into something like:

    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.5 (KHTML, like Gecko) Version/5.1 Safari/534.51.3
    

    This has nothing to do with the problems you’re encountering, but you don’t actually close your cURL socket, since you return before you close it (everything after return ... will be ‘skipped’).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site written in PHP utilizing PDO. I am using the bindParam()
I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
I have a code snippet written in PHP that pulls a block of text
I have a prototype website written in PHP. Lately i've rewritten code to separate
I have some code I've written in PHP for consuming our simple webservice, which
I have inherited some legacy PHP code what was written back when it was
I have a PHP script that creates other PHP files based on user input.
I currently have code like this in a web based file called 'view_file.php' to
I have written a PHP script that I would like to use on several
I have written a PHP script to write an XML document but there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.