mIRC Home    About    Download    Register    News    Help

Print Thread
$read from an url!? #125306 16/07/05 06:38 PM
Joined: Aug 2004
Posts: 42
T
The_Only Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Aug 2004
Posts: 42
Hi there... is it possible to read a line of a *.txt file from a remote location like an url for example. Or is there a way to read the whole txt file (again from an url) and place it into a dialog's "text" argument using did -a or somehow?

Thanks (again) :P

Re: $read from an url!? #125307 17/07/05 04:23 AM
Joined: Feb 2004
Posts: 45
N
Navid Offline
Ameglian cow
Offline
Ameglian cow
N
Joined: Feb 2004
Posts: 45
I've been meaning to ask the same question here smile but since you have it I'll just wait for a reply in here smile

Re: $read from an url!? #125308 17/07/05 06:25 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I assume this is no different than reading any other file from a website, then just reading down to the right line, or saving the whole file, and reading line X

Do a search of the forums for reading a webpage with sockets, would find you some code.

Re: $read from an url!? #125309 17/07/05 11:37 AM
Joined: Jan 2003
Posts: 249
C
ClickHeRe Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
You can using sockets to download the file and process it afterwards. Look around in scripting sites, there are plenty of examples of how this is done in snippets and addons.

Re: $read from an url!? #125310 17/07/05 01:25 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Here's a quick attempt, I've just got in from a 12 hour shift at work and I am knackered...

Code:
dialog web2dlg {
  title "Web 2 Dialog"
  size -1 -1 153 98
  option dbu
  edit "", 1, 2 2 147 93, multi hsbar vsbar
}

alias web2dlg {
  if ($1) set %find $1
  if (!$dialog(web2dlg)) dialog -dm web2dlg web2dlg
  sockopen web2dlg www.some-site-here.com 80
}

on *:sockopen:web2dlg: { 
  sockwrite -n $sockname GET /somefile.txt HTTP/1.1 
  sockwrite -n $sockname Host: www.some-site-here.com $+ $crlf $+ $crlf
}

on *:sockread:web2dlg: {
  if ($sockerr) {
    halt
  }
  else {
    var %w2d
    sockread %w2d
    if (%find) {
      if (%find isin %w2d) {
        did -a web2dlg 1 $strip(%w2d) $crlf
      }
    }
    else {
      did -a web2dlg 1 $strip(%w2d) $crlf
    }  
  }
}
on 1:sockclose:web2dlg: {
  echo -a Connection to Web 2 Dialog closed.
  unset %find
}


Usage:
/w2d - Lists the entire file if no keyword was used.
/w2d <keyword> - Lists all lines in the dialog with that keyword.

You may change the website, and file to whatever and if you know how sockets work you may change that name too.

-Andy

Re: $read from an url!? #125311 17/07/05 10:03 PM
Joined: Feb 2004
Posts: 45
N
Navid Offline
Ameglian cow
Offline
Ameglian cow
N
Joined: Feb 2004
Posts: 45
I tried that and I got this problem:
W2D Unknown command

Re: $read from an url!? #125312 18/07/05 12:04 AM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
I think he was referencing this alias :
Code:
alias  [color:blue]web2dlg [/color] {
  if ($1) set %find $1
  if (!$dialog(web2dlg)) dialog -dm web2dlg web2dlg
  sockopen web2dlg www.some-site-here.com 80
}

so either rename the alias to w2d or use /web2dlg

Re: $read from an url!? #125313 18/07/05 12:05 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Yep, oops! Sorry about that, I was soooo tired. frown

Re: $read from an url!? #125314 18/07/05 12:08 AM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
hows the new job going, they must be working ya hard frown

Re: $read from an url!? #125315 18/07/05 12:11 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
12 hours buddy, 6pm till 6am. It is hectic. The best part is using the golf carts and my radio (walkie talkie thingy...). smile

-Andy