3 Example Pipes Python Application
5 Connect to the pipe access point, retrieve the data and pretty-print
15 PIPE_HOST
= "http://www.botspiritcompany.com"
16 PIPE_ACCESS_POINT
= "/botlist/spring/pipes/search_pipes.html?querymode=enabled&query=bush"
18 def connectPipes
(url
):
19 request
=urllib2.Request
(url
)
20 request.add_header
('User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT')
21 opener
= urllib2.build_opener
()
22 data
= opener.open
(request
).
read()
25 def parsePipeData
(data
):
26 lines
= data.
split('\n')
29 url
, title
, list_datetime
= line.
split("\t")
30 print
"******************"
31 print
"title=%s\n url=%s" % (title
, url
)
33 print
"WARN: invalid format"
35 if __name__
== '__main__':
36 print
"running pipes connect"
37 fullURL
= "%s%s" % (PIPE_HOST
, PIPE_ACCESS_POINT
)
39 data
= connectPipes
(fullURL
)
42 diff_time
= end
- start
43 print
"executed in=%s" % diff_time