mIRC Homepage
Posted By: MTech sockets - 03/05/03 06:42 PM
1.) iv already looked at mirc.hlp and socket tutorals smile
2.) i'v looked at pre-existing scripts

and i still cant get it to work...

im trying to open a socket to www.azlyrics.com and get the lyrics for a song, by an artist

im useing %lyrx.art for artist name
and
%lyrx.tit for song title

i need it to open a socket to the page, and if it exists remove all of everything, expet the actuall lyrics and put it in the text box id 80
and if it dont exist just display Page not found, in text box 80

please help i have really tried to get this to work, but it doesnt
Posted By: MTech Re: sockets - 03/05/03 08:47 PM
can someone help?
Posted By: KingTomato Re: sockets - 03/05/03 09:18 PM
/sockopen lyrics www.azlyrics.com 80

on 1:SOCKOPEN:lyrics: {
if ($sockerr) { /set -u0 %err 4input(Error, o, Unable to connect to site!) }
else {
/sockwrite -n $sockname GET /lyrics/ [ $+ [ $replace(%lyrx.art, $chr(32), $+(%,20)) ] $+ ] / [ $+ [ $replace(%lyrx.tit, $chr(32), $+(%,20)) ] $+ ] .html HTTP/1.1
/sockwrite -n $sockname HOST: www.azlyrics.com
/sockwrite -n $sockname $crlf
}
if ($isfile(lyrics.htm)) .remove lyrics.htm
}

on 1:SOCKREAD:lyrics: {
/sockread -f &lyrics
/bwrite lyrics.htm -1 -1 &lyrics
}

on 1:SOCKCLOSE:lyrics: {
while (*:* iswm $read(lyrics.htm, 1)) {
/write -dl1 lyrics.htm
}
/run lyrics.htm
}

**untested**
Posted By: MTech Re: sockets - 03/05/03 09:40 PM
well it works, but i need it to insert the lyrics into a text box in a dialog... the $DID == 80
Posted By: KingTomato Re: sockets - 03/05/03 09:44 PM
read from the text file.. Do a query on about 5 songs and see if there is a "common" line where all lyrics begin at. If there is, then read from that line, until you hit another object that is similar in all cases.. Ex:

<html>
<heaD>
..blah blah
<td>
<tr>
Song Title

Lyrics Lyrics lyrics
...
..
Lyrics
</td>

In that case, you begin after the <td> and end when u hit the closing tag. Its just an example, and not based on the results, but just looka around. Most these parsing's can be ery easy. >:F
Posted By: MTech Re: sockets - 03/05/03 10:04 PM
im not having luck with that...
i can only get it to do exactly what you gave me
Posted By: KingTomato Re: sockets - 03/05/03 11:09 PM
on 1:SOCKOPEN:lyrics: {
if ($sockerr) { /set -u0 %err $input(Error, o, Unable to connect to site!) }
else {
/sockwrite -n $sockname GET $+(/lyrics/,$remove(%lyrx.art, $chr(32)),/,$remove(%lyrx.tit, $chr(32)),.html) HTTP/1.1
/sockwrite -n $sockname HOST: www.azlyrics.com
/sockwrite -n $sockname $crlf
}
if ($isfile(lyrics.htm)) .remove lyrics.htm
}

on 1:SOCKREAD:lyrics: {
/sockread -f &lyrics
/bwrite lyrics.htm -1 -1 &lyrics
}

on 1:SOCKCLOSE:lyrics: {
/set -u0 %l 1
while (%l <= 46) {
/write -dl1 lyrics.htm
/inc -u0 %l
}
/run lyrics.htm
}




that will leave you with the first line being the title.. Just read the txt file (Removing the html) all the way until you hit a double font close tag (</font></font>)
© mIRC Discussion Forums