-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchFlickr.py
More file actions
executable file
·50 lines (44 loc) · 1.61 KB
/
searchFlickr.py
File metadata and controls
executable file
·50 lines (44 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- conding:utf-8 -*--
print "Content-type: text/html\n\n"
import flickr
import cgi, cgitb
from graphbase.conexion import Conexion
cgitb.enable()
# Creamos instancia de FieldStorage
form = cgi.FieldStorage()
txtsch = form.getvalue("search")
#Variable para interactuar con la bdog
con = Conexion()
#Busqueda en Base
print "-"
print "<ol>"
palabras = txtsch.split()
for palabra in palabras:
nodos = con.searchNodesFlickr(palabra)
for nodo in nodos:
print "<li><p>Title: %s" % nodo.values[0]['title'].encode('utf-8')
print "<br />Publicado en: %s" % nodo.values[0]['datetaken']
print "<br />Tags: %s" % nodo.values[0]['tags'].encode('utf-8')
print "<br />URL: <a href=%s target='_blank'>%s</a>" % (nodo.values[0]['url'],nodo.values[0]['url'])
print "</p></li>"
#Busqueda en Flickr
print "-"
photos = flickr.photos_search(tags=txtsch, tag_mode='all', per_page=5)
for photo in photos:
op = con.searchNodeDuplicated(photo.url, "Image")
if (op == 0) :
try:
print "<li><p>Title: "+photo.title+ "<br />"
print "Publicado en: "+photo.datetaken + "<br />"
print "Tags: "
tagsc = ""
for tag in photo.tags:
tagsc = tagsc + tag.text +" "
print tag.text.encode('utf-8')
print "<br />URL: <a href=%s target='_blank'>%s</a>" % (photo.url,photo.url)
print "</li>"
con.createNodeImageFlickr(photo.id, photo.title, photo.url, photo.datetaken, tagsc.encode('utf-8'))
except:
continue
print "</ol>"