File: _web_example1.py

package info (click to toggle)
nodebox-web 1.9.4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,904 kB
  • ctags: 1,602
  • sloc: python: 7,582; ansic: 581; xml: 239; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Working with URL's.

from nodebox_web import web

# Is this a valid URL?
print web.is_url("http://nodebox.net")

# Does the page exist?
print web.url.not_found("http://nodebox.net/nothing")

# Split the URL into different components.
url = web.url.parse("http://nodebox.net/code/index.php/Home")
print "domain:", url.domain
print "page:", url.page

# Retrieve data from the web.
url = "http://nodebox.net/code/data/media/header.jpg"
print web.url.is_image(url)
img = web.url.retrieve(url)
print "download errors:", img.error