python通过mechanize模块实现不断刷新网页的功能,你可以通过命令行指定一个网页,程序将通过浏览器打开此页面并且不断的刷新,可以通过键盘随时终止,mechanize模块可以通过easy_install或者pip安装
import mechanize import sys def usage(): print "Usage: python" + ' ' + sys.argv[0] + ' ' + "<url>" sys.exit() def reloader(): br = mechanize.Browser() reload_count = 0 url = sys.argv[1] start = br.open(url) while True: try: br.reload() reload_count += 1 print "[+] Sent reload request", "%s" % (reload_count) except KeyboardInterrupt: sys.exit("\nProcess aborted.") if len(sys.argv) < 2: usage() if __name__ == "__main__": reloader()