Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / web / examples / dlpage.py
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 This example demonstrates how to use downloadPage.
6
7 Usage:
8     $ python dlpage.py <url>
9
10 Don't forget the http:// when you type a URL!
11 """
12
13 from twisted.internet import reactor
14 from twisted.web.client import downloadPage
15 from twisted.python.util import println
16 import sys
17
18 # The function downloads a page and saves it to a file, in this case, it saves
19 # the page to "foo".
20 downloadPage(sys.argv[1], "foo").addCallbacks(
21    lambda value:reactor.stop(),
22    lambda error:(println("an error occurred",error),reactor.stop()))
23 reactor.run()