mIRC Home    About    Download    Register    News    Help

Print Thread
#128470 25/08/05 05:00 PM
Joined: Aug 2005
Posts: 2
M
MrLint Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Aug 2005
Posts: 2
I want mirc to access (and take out some parts of the file, but guess I can figure that one out later smile) a .txt file on the internet. How would I go about this?

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
the mIRC help for sockets has a good example of how to do this
a bit confusing due to the complexity of sockets
Code:
;;open a socket
/sockopen socktest www.mirc.co.uk 80

;;when the socket opens, request the file from the server
on *:sockopen:socktest: sockwrite socktest GET http://www.mirc.co.uk/whatsnew.txt $+ $crlf

;; when the socket has data,  read the data and do something with it
;; in this case color it red and echo to status
on 1:sockread:socktest:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  echo 4 -s %temp
  goto nextread
}

Joined: May 2005
Posts: 449
Fjord artisan
Offline
Fjord artisan
Joined: May 2005
Posts: 449
I haven't done anything with sockets either, but I have a question too. Is there a way to write an alias using sockets to pull a dictionary definition from dictionary.com? The URL in the script would be http://dictionary.reference.com/search?q= $+ $1- . Thanks.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
using the search feature on this forum for the word "dictionary" revealed this thread Click Here

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just as a note... dictionary.com is a HORRIBLE site to try to socket definitions from because of the way their HTML is set up.

You're better off using another dictionary site. Search for a word on various sites and then view the page source in your browser. If the lines are short and there is a way you can see to find the definition on the page (such as only the definition line starting with something like <class="definition"> or <font size=+1> or something else that isn't found all over the page), then it would be a good one for using in a script.

Usually, once you find a good site, the difficulty is keeping the verb/noun/etc definitions separated out. But, that's something to mess with after you find a site you like. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
I suggest you cheat by taking a look at an existing widget that does this and then you'll have a good blueprint on how to parse the needed data.


Beware of MeStinkBAD! He knows more than he actually does!
Joined: Aug 2005
Posts: 2
M
MrLint Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Aug 2005
Posts: 2
This was helpful, thanks. But the problem is the .txt file is 4000 lines long and it echoes all of it, how can I make it paste only one line? A start would be to paste in a specific line in a channel, but I would also like to make it trigger on something on the line so it will paste the entire line. Any help is appreciated laugh

This is the url of the file http://e3.swirve.com/data/ranks.txt


Link Copied to Clipboard