I’m playing around with the robotparses library, and I’m trying out the example program from:
http://docs.python.org/library/robotparser.html
My code is currently-
import robotparser
def TestMain():
#Check robots.txt
rp = robotparser.RobotFileParser()
rp.set_url("http://www.musi-cal.com/robots.txt")
rp.read()
rp.can_fetch("*", "http://www.musi-cal.com/cgi-bin/search?city=San+Francisco")
The problem I’m running into is that when I run the code it runs successfully, but doesn’t return anything, anyone have any idea why?
Thanks
The example you are refering to is for interactive use in the interpreter and not a standalone program. You can’t produce anything meaningful just by adding a
defstatement. For your function to return something there has to be anreturnstatement. And to use a function you have to call it.Here’s a python book that should explain how to construct functions and turn them into programs.