mIRC Home    About    Download    Register    News    Help

Print Thread
#30465 17/06/03 09:11 PM
Joined: Jun 2003
Posts: 4
V
vardhan Offline OP
Self-satisified door
OP Offline
Self-satisified door
V
Joined: Jun 2003
Posts: 4
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
}


/server -m 216.152.65.156
/join #project64
#30466 18/06/03 09:28 AM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
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)


new username: tidy_trax
#30467 18/06/03 09:43 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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


-KingTomato
#30468 18/06/03 09:54 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
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
}


new username: tidy_trax
#30470 18/06/03 08:05 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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 >:\


-KingTomato
#30471 19/06/03 06:25 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
o watever.. >:\


-KingTomato
#30473 22/06/03 01:36 AM
Joined: Mar 2003
Posts: 50
C
Babel fish
Offline
Babel fish
C
Joined: Mar 2003
Posts: 50
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