To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.generalOpen lugnet.general in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 General / 5694
5693  |  5695
Subject: 
Perl-based bulk set IDer...
Newsgroups: 
lugnet.general
Date: 
Wed, 21 Jul 1999 00:52:29 GMT
Viewed: 
1028 times
  
Hello fellow Lego freaks^H^H^H^H^Hans,

(Warning this may appeal to Unix and Perl geeks only...)  Not long ago when
I was trying in a feverish sort of way to re-establish a Lego collection
that I dreamt of as a kid, I put together a Perl script that could scan text
for Lego set ids and query the Lugnet set database and return a nice summary
of the Lego sets.  So for instance if I copied the text from auction
http://cgi.ebay.com/aw-cgi/eBayISAPI.dll?ViewItem&item=134412271 that
contained the set ids and pasted it into the script, it would spit out the
following:

                               Lego Sets
-------------------------------------------------------------------------------
ID   Name                        Theme                    Year MSRP($)  Pcs Fgs
-------------------------------------------------------------------------------
4021 Police Patrol               Boats/General            1991  34.00    185  3
6057 Sea Serpent                 Castle System/Black Knig 1992  16.50    117  5
1481 {Unnamed}                   Pirates/General          1991   0.00?  {20}  1
6268 Renegade Runner             Pirates/General          1993  39.75    171  4
6278 Enchanted Island            Pirates/Islanders        1994  66.00    412  7
6933 Spectral Starguider         Space/Blacktron II       1991  28.50    204  2
6983 Ice Station Odyssey         Space/Ice Planet 2002    1993  67.00    337  3
6896 Celestial Forager           Space/M:TRON             1990   0.00?    87  1
6957 Solar Snooper               Space/Space Police II    1992  35.99?   249  3
6889 Recon Robot                 Space/Spyrius            1994  13.25    133  1
6835 Saucer Scout                Space/Spyrius            1994   4.50     45  1
6949 Robo-Guardian               Space/Spyrius            1994  38.50    360  3
6345 Aerial Acrobats             Town/Flight              1993  34.00    331  6
1477 {Unnamed - Part of 1476 5-  Town/Race                1991   0.00?  {34}  1
     Item Bonus Pack}
-------------------------------------------------------------------------------
Sets: 14  ||  Est. cost: $377.99  (3 unknown)  ||  Number of pieces: 2685
-------------------------------------------------------------------------------

...which gives a rough idea of what it is you're bidding on.  Since I've
blown way too much money on Lego recently and I'm going on vacation I
figured I might as well let the Lego community at large access to the
script.

The script source is located at: http://www.stanford.edu/~zeade/legoid

It'll only run on a Unix/Linux box that has both Perl5 and the LWP (a very
handy web library) package installed (I think LWP is included in the
standard distribution now).  You'll also need to replace the first line of
the script with the path to where ever you have Perl installed on your
system.

Some notes: it's pretty dumb about scanning for sets.  It picks up any 3-4
digit numbers and assumes it's a Lego set id.  It's also pretty dumb about
scanning the HTML returned from the lugnet search query, meaning if the
format of the HTML were to change drastically, then the script is b0rken.
What can I say, it was something I whipped up while avoiding something less
interesting at work for a couple hours.  It also doesn't try in anyway try
to deal with id collisions (i.e. if you feed it 6077, it'll just give spit
it out as an unknown set, called "(???)").

This is a work independent of Lugnet and is not affiliated officially in any
way.  As far as I can see this doesn't violate any of the Lugnet Terms of
Use statement and I've tried to liberally acknowledge that all set
information is coming from Lugnet.

I'm not sure if I'll be expanding it in any way, but I'll take requests for
enhancements.


have fun,
Micah
--
perl -e's;^;nsiC%by:n19%o>o2z4on19%`"t2z`fn3o.%.2o.z.2o.g4og.5o.g.4o.4%;;\
s;$;f%.2o.n`fP"Y2>bP"Y2>bz`fzd2>t%`"Y>%`Pz)2>bgfP"Y2>bn%p#f8%.oP"#n%p#p;;\
s;$;.o>%d>(z#n____`Y>bod>Pt%`Yf2">o%__n;;s;#;ppfz;g;s;p;fg;g;s;_;ofo%;g;;\
s;z;2%;g;s;g;3%;g;s;f;3>;g;s;(\d+)(.);$2x$1;eg;y;t>%nC;\x278 \ng;;print;'



Message has 1 Reply:
  Re: Perl-based bulk set IDer...
 
(...) Say, did you know about the "output=plain" option? For example, (URL) a simpler output mode which makes parsing easier, and it's much less bandwidth (about 1/10 the page size). Actually, rather than parsing, it was really created for the (...) (25 years ago, 21-Jul-99, to lugnet.general, lugnet.admin.general)

6 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR