aslambilal's forum posts

  • 11 results
  • 1
  • 2
#1 Posted by aslambilal (11 posts) - - Show Bio

I'm getting a 101 error on my search.  ( Object not Found )
 
 http://api.comicvine.com/character/248/?api_key=900dc244acd37006ea3be1b8eaed36630e73e448&format=json
<?xml version="1.0" encoding="UTF-8" ?>
<response><error><![CDATA[Object Not Found]]></error><limit>0</limit><number_of_page_results>0</number_of_page_results><number_of_total_results>0</number_of_total_results><offset>0</offset><results></results><status_code>101</status_code></response>

 

#2 Posted by aslambilal (11 posts) - - Show Bio

Well i'm still trying to figure out how to get rails to talk with javascript frameworks so that i can have a neat UI for my rails comic organizer. WIsh i knew where to start lol.

#3 Posted by aslambilal (11 posts) - - Show Bio

I think we're about 1.5 weeks too late Red LAMP.

#4 Posted by aslambilal (11 posts) - - Show Bio

Hey, i'm trying to do something very similar too! Not for class, more as a hobby in my off time. If you are allowed random help and are going to be working with Ruby on Rails ( MVC Web Framework ) please let me know.
 
As to your question, i dont know much about desktop programming, Java would be the easiest to make a gui with and there's tons of help for that.
I'm trying to learn ruby and ruby on rails, so i'm trying to make a web app that will catalogue comics for multiple users.
 
If you try the api, you'll learn that it's not good for querying search data and the best bet is to create a local database to move the api information into.

#5 Posted by aslambilal (11 posts) - - Show Bio

Hello ggkilmon
 
Sorry about the late reply, i don't come around here very much lately, i've been busy with stupid LSAT stuff.
I believe you are correct in assuming there is too much information being returned because when i goto this url  

http://api.comicvine.com/character/1443/?api_key=(API)&format=xml&field_list=story_arc_credits

It works perfectly fine.
I remember for my own purposes i did not need all the fields that are supplied, so you could say something like

http://api.comicvine.com/character/1443/?api_key=(API)&format=xml&field_list=story_arc_credits,name,aliases,real_name 

And use only the fields you are going to need. However if you do need all the fields, i'd suggest using 2 separate queries each with 1/2 the info or so to grab all the characters reliably.
 
Let me know if this works for you :)
#6 Posted by aslambilal (11 posts) - - Show Bio

Ok, looking at

http://api.comicvine.com/volume/2294/?api_key=(API)&format=xml&field_list=issues

The very last issue in results is the first one on this page
http://www.comicvine.com/thor/49-2294/?sort=issue_number

Second last is second on same page
Third last is third and so forth

Which seems to me it's sorting by issue ID from Highest to Lowest, or most recent to least assuming the issues were added sequentially in a timely manner, so you only have to grab the first/last issue and check if the numbers match. Or check once very 25? issues. For Example

1
..
25 - do you have 25 entries and on issue 1 + 24? good
..
50 - do you have 50 entries and on issue 25 + 24? good
..
75 - do you have 75 entries and on issue 50 + 24? good
..
100 - do you have 100 entries and on issue 75 + 24 ? no, go back however many results you have ( you wont have 25 ) and check where it breaks down? ( check my algorithm, i scaped by in college )

I wish we could have sort=id and sort=!id or something for reverse lol but who am i to complain? this is my first api that i'm learning.

Let me know if this works out for you. I'd really like to know.

#7 Posted by aslambilal (11 posts) - - Show Bio

Hello,


Ok, so if i wanted to keep a local db of the information here would that be ok?

Here's my reasoning, groing through the list of 42500ish character results from the xml takes a long time and takes a long time ( unless i multithread it ). Is it ok if i keep local tables say | Char Name - ID | so that i can do my xml searches a little easier? Or am i missing something?

The reason i bring this up is because say my user searches for say "bat" because he doesnt remember batman's name, the api doesnt have search functions related to things like that, does it?
#8 Posted by aslambilal (11 posts) - - Show Bio

Code Update:


#BEGIN

require 'rexml/document'
require 'net/http'
require 'open-uri'

def extractcdata( input )
  input.to_s[7..(input.to_s.size-3)]
end

url = "http://api.comicvine.com/characters/?api_key=(API)&sort=name&format=xml"

xml = open( url )

# xml = File.read( 'characters.xml' )

x = 0

regex = Regexp.new(  /\[.*\]/ )

doc, characters = REXML::Document.new( xml ), []
doc.elements.each( 'response/results/character/name' ) do |name|
  x = x + 1
  matchname = regex.match( name.to_s )
  if matchname
    characters << extractcdata( matchname[0] )
  else
    puts "NO MATCH: " + name
  end
end

puts characters
puts x

#END

Comment - Output is not sorted by name of character. Any idea why?

#OUTPUT
Lightning Lad
Dream Girl
Brainiac 5
Invisible Kid
Phantom Girl
Sun Boy
Star Boy
Shadow Lass
Triplicate Girl
Element Lad
Cosmic Boy
Micro Lad
...
#END
#9 Posted by aslambilal (11 posts) - - Show Bio

Thanks :)


I've been using google and searching "ruby tutorial" "rails 2.x tutorial" or combinations. Not being able to find a job these days leaves me with too much spare time. I may start studying for the LSATs soon as well if nothing happens.
#10 Posted by aslambilal (11 posts) - - Show Bio

So i ended up trying a different xml parsing library and this gave me better resuls. I'm gonna tinker with the old one and see if i can get the same output later. Thanks for your reply Mabster


# Begin Code
require 'rexml/document'

def extractcdata( input )
  input.to_s[9..(input.to_s.size-4)]
end

xml = File.read( 'characters.xml' )

x = 0

doc, characters = REXML::Document.new( xml ), []
doc.elements.each( 'response/results/character/name' ) do |c|
  x = x + 1
  characters << extractcdata( c.innerHTML )
end

puts characters
puts x
# End Code
  • 11 results
  • 1
  • 2