Skip to content

Instantly share code, notes, and snippets.

@sahib
Created September 30, 2011 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sahib/1255277 to your computer and use it in GitHub Desktop.
Save sahib/1255277 to your computer and use it in GitHub Desktop.
require './glyros.so'
include Glyros
# Simple example on how to directly call a certain
# provider's get_url() and parser() function.
# We need a query (as usual)
q = GlyrQuery.new
glyr_query_init(q)
glyr_opt_artist(q,"Equilibrium")
# Ask the photo:picsearch provider where it looks for data.
url = glyr_testing_call_url("picsearch",GLYR_GET_ARTIST_PHOTOS,q)
# Download the pagesource of this url.
page_source = glyr_download(url,q)
# Now run photo:picsearch's parser on it. It will return (similar to glyr_get()) a linked list
# of caches. Note: Actually it does something different, but it gets converted to a linked list :-)
list = glyr_testing_call_parser("picsearch",GLYR_GET_ARTIST_PHOTOS,q,page_source)
# Iterate over all results to demonstrate it
# Set glyr_opt_number to e.g. 5 to get more of it.
# In this cases you'll just get urls, no read images.
head = list
until head.nil?
glyr_cache_print(head)
head = head.next
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment