| 1 | # robot_detection |
| 2 | |
| 3 | robot_detection is a python module to detect if a given HTTP User Agent is a web crawler. It uses the list of registered robots from http://www.robotstxt.org: (Robots Database)[http://www.robotstxt.org/db.html) |
| 4 | |
| 5 | ## Usage |
| 6 | |
| 7 | There is only one, function, ``is_robot`` that takes a string (unicode or not) and returns True iff that string matches a known robot in the robotstxt.org robot database |
| 8 | |
| 9 | ### Example |
| 10 | |
| 11 | >>> import robot_detection |
| 12 | >>> robot_detection.is_robot(user_agent_string) |
| 13 | |
| 14 | ## Updating |
| 15 | |
| 16 | You can download a new version of the Robot Database from [this link](http://www.robotstxt.org/dbexport.html). |
| 17 | |
| 18 | Download the database dump, and run the file ``robot_detection.py`` with the file as first argument. |
| 19 | |
| 20 | $ wget http://www.robotstxt.org/db/all.txt |
| 21 | $ python robot_detection.py all.txt |
| 22 | |
| 23 | If the database has changed, it'll print out the new version of ``robot_useragents`` variable that you need to put into the source code. |
| 24 | |
| 25 | ## Tests |
| 26 | |
| 27 | Some simple unittests are included. Running the ``tests.py`` file will run the tests. |