mIRC Home    About    Download    Register    News    Help

Print Thread
#30465 17/06/03 09:11 PM
V
vardhan
vardhan
V
I can get this Google Searcher to work, anyone got an idea of whats wrong?
alias search {
sockclose google
set %search $replace($1-,$chr(32),+)
sockopen google www.google.com 80
}
on *:sockopen:google:{
if ($sockerr > 0) { return }
sockwrite -n google GET /search?q= $+ %search $+ &ie=UTF-8&oe=UTF-8&hl=en&meta=)
sockwrite -n google HOST www.google.com $+ $crlf $+ $crlf
}
on *:sockread:google:{
sockread %result
echo -a $chr(32) $htmlfree(%result)
}
alias htmlfree {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
return %x
}

#30466 18/06/03 09:28 AM
P
pheonix
pheonix
P
there's no need to post the same question on multiple boards, just simply post on 1 board and be patient for your answer(s)

#30467 18/06/03 09:43 AM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
as was pointed on on the other board...

sockwrite -n google GET /search?q= $+ %search $+ &ie=UTF-8&oe=UTF-8&hl=en&meta=)
sockwrite -n google HOST www.google.com $+ $crlf $+ $crlf

needs to be more like..

sockwrite -n google GET /search?q= $+ %search HTTP/1.0
sockwrite -n google HOST www.google.com
sockwrite -n google $crlf

It might be better if u had atleast some farmiliarity with the http protocol

#30468 18/06/03 09:54 AM
Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
Actually that's wrong, first you need a : after the word "host", and second you don't need the $crlf at the end of the third sockwrite..

#30469 18/06/03 10:40 AM
P
pheonix
pheonix
P
sockclose google
set %search $replace($1-,$chr(32),+)
sockopen google www.google.com 80
/sockmark google /search?q= $+ %search $+ &ie=UTF-8&oe=UTF-8&hl=en&meta=)
}
on *:sockopen:google:{
if ($sockerr > 0) { return }
sockwrite -n google GET $sock($sockname).mark HTTP/1.1
sockwrite -n google ACCEPT: */*
sockwrite -n google HOST: www.google.com $+ $crlf $+ $crlf
}
on *:sockread:google:{
sockread %result
echo -a $chr(32) $htmlfree(%result)
}
alias htmlfree {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
return %x
}

#30470 18/06/03 08:05 PM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
heh..knew i shouldn't have attepted that b4 i went to bed. Yes, hopst: has a colon, and the crlf is so there is a file return after the host is sent, symbolizing EOH (end of header). Anyways, if you don't put tsomething, it gives the "insifficient params" line >:\

#30471 19/06/03 06:25 AM
Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
Quote:
Anyways, if you don't put tsomething, it gives the "insifficient params" line >:\

Not for me, I have many HTTP scripts that do it, all of them use sockwrite -n $sockname, the -n sends a $crlf, don't need another $crlf. I like quibbling over details.

#30472 19/06/03 07:26 AM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
o watever.. >:\

#30473 22/06/03 01:36 AM
C
coolspot
coolspot
C
However, even using -n sometimes doesnt work and you will still get the invalid parameters error. I had this happen commenly on sites using IIS 5+ where I had to actually send a seperate $crlf all by its lonesome. Unsure why IIS has this problem at times, maybe its the way its waits for the entire header sequence.


Link Copied to Clipboard