mIRC Home    About    Download    Register    News    Help

Print Thread
#22172 03/05/03 06:42 PM
Joined: Mar 2003
Posts: 437
M
MTech Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Mar 2003
Posts: 437
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

#22173 03/05/03 08:47 PM
Joined: Mar 2003
Posts: 437
M
MTech Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Mar 2003
Posts: 437
can someone help?

#22174 03/05/03 09:18 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
/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**


-KingTomato
#22175 03/05/03 09:40 PM
Joined: Mar 2003
Posts: 437
M
MTech Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Mar 2003
Posts: 437
well it works, but i need it to insert the lyrics into a text box in a dialog... the $DID == 80

#22176 03/05/03 09:44 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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


-KingTomato
#22177 03/05/03 10:04 PM
Joined: Mar 2003
Posts: 437
M
MTech Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Mar 2003
Posts: 437
im not having luck with that...
i can only get it to do exactly what you gave me

#22178 03/05/03 11:09 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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>)


-KingTomato

Link Copied to Clipboard