mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
howdy agian all,

... still working this imdb search script... BUT, i have a different question.... in this part of the code:
Code:
on *:sockopen:movieinfo1: { 
  sockwrite -n $sockname GET /find?q= $+ $replace(%movietitle,$chr(32),$(%20,)) $+ ;s=all HTTP/1.1 
  sockwrite -n $sockname Host: www.imdb.com $+ $crlf $+ $crlf 
  set %zinfonumber 1 
  ;echo -at Succesfully Opened Socket 
} 
on *:sockread:movieinfo1:{ 
  if ($sockerr) { 
    ;echo -a Error 
    Halt 
  } 
  else { 
    var %tmptxt 
    sockread -f %tmptxt 
    ;echo -a %tmptxt 
    if (Location: isin %tmptxt) { 
      set %movieinfolink2 $remove(%tmptxt,Location: http://www.imdb.com) 
      sockopen movieinfo2 www.imdb.com 80 
    } 
    else { 
      if (<p><b>Popular Titles</b> isin %tmptxt) { 
        set %movieinfolink2 $gettok(%tmptxt,2,34) 
        echo -a %movieinfolink2 
        sockopen movieinfo2 www.imdb.com 80
      } 
    }
  } 
} 
  

it opens socket 1 and starts the search blah,blah,blah.. which is fine. but however the search page comes up with multiple results for same title example:
Quote:

Popular Titles (Displaying 2 Results)

All the King's Men (1949)
All the King's Men (2006)

the code as is grabs the first link it sees (basicly) in the search results and proceeds to open that with the second socket..
so my question is this:
how can i catch all the links in this part of page and have them listed in a list box? i pretty much can figure out the rest from there..
here's what the sorce code looks like:
Quote:

<p><b>Popular Titles</b> (Displaying 2 Results)<ol><li> <a href="/title/tt0041113/" onclick="set_args('tt0041113',1,1)">All the King's Men</a> (1949)</li>
<li> <a href="/title/tt0405676/" onclick="set_args('tt0405676',2,1)">All the King's Men</a> (2006)</li>
</ol>
</p>


please if anyone can help.. it would be appreciated greatly!

thanks in advance

**EDIT - in addition is it possible to have those links look as they do on the page for easy selection in the list box?

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Its pretty simple really, dont trigger sockopen movieinfo2 www.imdb.com 80 until movieinfo1 is done reading the entire buffer. And instead of setting the movie into a variable do a did -a smile

Yes it would be possible have a hidden window for the URL's and the listview for the titles. $did(dialog,id,1) would correspond with $fline(@window,*,1,0). Or you can use a 0 width column with multi column listviews thanks to DCX


$maybe
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
ok i pretty much understand what your saying.... but my delemma is this(and i'm just being honest).... i'm really not all that great of a scripter and my experience is limited .. sockets is a whole new realm for me. so, i'm not sure how to go about looping thru the string to find all the possible results that may popup from the search.. it was suggested that i should use regex for this but, i know nothing about it... oh-hum... guess i'm gonna have to look it up.... confused

i don't really expect for anyone to do this for me(as some may think) sooo...
if you wish mpdreamz you could assist me further with some pointers or maybe some other suggestions .... it would be appreciated

thanks for responding cool

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
ok well where you set your var now you can use this:
if($regex(%tmptxt,/<a .+?"(.+?)".+?>(.+?)</a>(.+?)</li>)) $regml(1))

to see if the line has a movie title init. After that if statement you can use $regml(1) to reference to the url $regml(2) for the title and $regml(3) for the year.

note: The regex might need some tweaking though i have only done 3 searches.

if (%tmptxt == </html>) sockopen movieinfo2 www.imdb.com 80

If you want multi column listviews i suggest you try out DCX.

Im sorry for not posting out a fully working snippet but i firmly believe that will take all the fun away for you smile


$maybe

Link Copied to Clipboard