www.webdeveloper.com
Results 1 to 2 of 2

Thread: Pinging Google

  1. #1
    Join Date
    Jun 2008
    Posts
    219

    Pinging Google

    Hi, I've had a blowout on an old script to ping a search engine for my page and am wondering if this one is right.

    Has anyone experience with these things?
    I did check Google's page about this and the xml appears to be in line with what they say there.
    I know that using a pinging service can take ages, which is why I'm just pinging Google direct.

    Code:
    #!/usr/bin/perl
    
    use strict;
    use warnings;
    require LWP::UserAgent;
    
    my $site_name = 'Site Name';
    my $site_url = 'http://www.msite.com/';
    my $site_rss = 'myblog.xml';
    
    my %urls = (
        'Google' => 'http://blogsearch.google.com/ping/RPC2',
    );
    
    my $content = <<EOF;
    <?xml version="1.0"?>
    <methodCall>
      <methodName>weblogUpdates.ping</methodName>
      <params>
         <param><value>$site_name</value></param>
         <param><value>$site_url</value></param>
         <param><value>$site_rss</value></param>
      </params>
    </methodCall>
    EOF
    
    foreach my $site (keys %urls) {
        print "Pinging $site...";
    
        my $req = HTTP::Request->new('POST', $urls{$site});
        $req->content_type('text/xml');
        $req->content($content);
    
        my $ua = LWP::UserAgent->new;
        $ua->request($req)->as_string;
    }
    Any help would be appreciated,
    many thanks

  2. #2
    Join Date
    Jun 2008
    Posts
    219
    Turns out this is okay, but it doesn't tell me when it has finished like my old one did.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles