1

Try to submit a query in Wikipedia by using snoopy class in PHP but fail

<?php
        include "Snoopy.class.php";
        $snoopy = new Snoopy;

        $snoopy->agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 FirePHP/0.2.1";
        $snoopy->referer = "http://www.google.com/";

        $url = "http://www.wikipedia.org/";

        $data["search"] = "Intel";
        $data["language"] = "en";
        $data["go"] = "submit";

        $snoopy->submit($url, $data);
        echo $snoopy->results;
?>

It's seems can't submit the query to wikipedia and return error. What's wrong with the code above? Thanks!!

Here is the error message from wiki

Fireghost
  • 129
  • 2
  • 12

1 Answers1

3

Don't scrape Wikipedia. They have an API.

http://en.wikipedia.org/w/api.php

  • I try to use wikipedia to learn snoopy class as it can pretend a real browser. So, did I miss something in snoopy as wikipedia treat me as a program but not a browser? – Fireghost Oct 10 '12 at 03:15
  • I believe Wikipedia takes steps to block scrapers. Scrape some other site instead. –  Oct 10 '12 at 04:37