mIRC Home    About    Download    Register    News    Help

Print Thread
#29928 15/06/03 09:56 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
please dont laugh at me for this, but this is my 1st attempt at using sockets and i was wondering where abouts ive gone wrong in this and if anyone can help me with it please grin

alias google.search {
/sockopen google google.com 80
.set %search $1-
}
on 1:SOCKOPEN:google:{
/sockwrite -n google search?hl=en&ie=UTF-8&oe=UTF-8&q= $+ %search
}
on 1:SOCKREAD:google:{
if ($sockerr > 0) {
return
}
sockread %s
//echo -a %s
}
it echos this:

<HEAD><TITLE>Invalid HTTP Request</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Invalid HTTP Request</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: Bad request syntax</B></FONT>
<HR>
<!-- default "Invalid HTTP Request" response (400) -->
</BODY>
<HEAD><TITLE>Invalid HTTP Request</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Invalid HTTP Request</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: Bad request syntax</B></FONT>
<HR>
<!-- default "Invalid HTTP Request" response (400) -->
</BODY>

as u mite of guessed i was expecting it to search google for %search

thanx in advance smile


new username: tidy_trax
#29929 15/06/03 10:15 PM
Joined: Jan 2003
Posts: 148
K
Vogon poet
Offline
Vogon poet
K
Joined: Jan 2003
Posts: 148
First of all, try to use www.google.com 80

And then see what happens

#29930 15/06/03 10:19 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
That won't correct anything, his problem is he isn't using the HTTP protocol, he's just sending the server text, which it won't understand. http://www.ietf.org/rfc/rfc2616.txt That describes the current HTTP protocol.

#29931 16/06/03 07:32 AM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
thanx but i dont really understand that frown
could you give me a small example please.


new username: tidy_trax
#29932 16/06/03 07:33 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
read the protocol before you start messing with it k thnx. Even if ppl were to give you the code, you;'d still not understand it--be clueless, then be back asking another question in a day or so.


-KingTomato
#29933 16/06/03 08:00 AM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
i looked over the get,host,http/1.1 sections and i managed to get it to search now grin now i just gotta figure out how to remove all the <html> etc


new username: tidy_trax
#29934 16/06/03 10:59 AM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
alias google.search {
.set %search $1-
/write -c search.txt search results from google for: %search
/sockclose google
/sockopen google google.com 80
.sockmark google /search?hl=en&ie=UTF-8&oe=UTF-8&q= $+ %search
}
on 1:SOCKOPEN:google:{
/sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
/sockwrite -n $sockname accept: */*
/sockwrite -n $sockname host: www.google.com
/sockwrite -n $sockname $crlf
}
on 1:SOCKREAD:google:{
if ($sockerr > 0) { return }
sockread %s
/write search.txt %s
}
on tidy:TEXT:`google.search*:#:{
$google.search($2-)
}
on tidy:TEXT:`search.result:#:{
amsg $search.result
}
alias search.result {
var %i 1
while ($read(search.txt,*,%i,w) != $null) {
$read(search.txt,*,%i,w)
inc %i
}
}
that returns my search with loads of <html> codes in it, do i have to use $gettok to remove the html code, and just /write the sites? or is there a simple way?
thanx in advance. smile

Last edited by pheonix; 16/06/03 11:05 AM.

new username: tidy_trax
#29935 16/06/03 02:59 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Probably the best way to remove HTML tags would be to use $regsub.

#29936 16/06/03 03:36 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
could it not be done using tokenize?


new username: tidy_trax
#29937 16/06/03 06:06 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
lmao tokenize? Sure, make ur life harder.. Haha

<a href="http://some.link/>My Text</a><br><hr color="#FFFFFF"><br><font color="#CCCCCC">Hello There</font>

Okay, now using tokenize 32

$1 = <a
$2 = href="http://some.link/>My
$3 = Text</a><br><hr
$4 = color="#FFFFFF"><br><font
$5 = color="#CCCCCC">Hello
$6 = There</font>

Or even by the < character

$1 = a href="http://some.link/>My Text</a
$2 = /a>
$3 = br>
$4 = hr color="#FFFFFF">
$5 = br>
$6 = font color="#CCCCCC">Hello There
$7 = /font>

Amazing, its now in plain text! grin


-KingTomato
#29938 16/06/03 06:12 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
i could maybe do it using about a thousand gettoks frown but im sure theres an easier way as ive seen 15 line google searches before frown


new username: tidy_trax
#29939 16/06/03 06:24 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
You know what patter searching is? Every google responce has a template. Its always going to be link, then maybe either a "Translate this page" or "cached page" following, then description. Look for those things, and break it down. Besides, if you take away html, how are you going to tell the user what the link is to one of your finds? e.g. if i type "!googesearch kingtomato" and it comes up with

<ChanSys> Google Results:
<ChanSys> 1. KingTomato's Palace
<Chansys> (... If you wanna chat, you can catch me at <a href="irc://irc.dynamix.com/king-tomato" target="_blank">irc://irc.dynamix.com/king-tomato</a> -Peace.
Posted by KingTomato on Monday, March 10 @ 07:53:26 EST (3 reads) (Read More... ...)
<ChanSys> 2. Viewing list of forums - Forums powered by UBB.threads
<ChanSys> (... 1099, 4494, 14/06/2003 23:17 by KingTomato. Connection Issues, ... 2148, 11877, 04/06/2003 23:23 by KingTomato. Development, Threads, Posts, Last post. Feature Suggestions, ... )

Now, how do I click the link to the second one, if the <a> html tag was removed?


-KingTomato
#29940 16/06/03 06:36 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
i write the results to a text (html included) and im looking to message the results removing the html.....


new username: tidy_trax
#29941 17/06/03 06:55 AM
Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
You can remove all tags with my oldie alias ..

Alias RemTags {
var %ToRem,%i = 1
var %SCount = $pos($1-,<,0)
var %Rez = $remove($1-,&nbsp)
while (%i <= %SCount) {
%ToRem = $mid(%Rez,$pos(%Rez,<,1),$calc($pos(%Rez,>,1) - $pos(%Rez,<,1) +1 )))
%Rez = $replace(%Rez,%ToRem,$chr(32))
inc %i
}
return %Rez
}

//echo $RemTags(<a href="http://some.link/>My Text</a><br><hr color="#FFFFFF"><br><font color="#CCCCCC">Hello There</font>) - return My Text Hello There


mIRC Chm Help 6.16.0.3 Full Anchored!
#29942 17/06/03 07:50 AM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
thanx but now i still have 1 problem, i want to display the www.somelink.com but not the <a href=" ></a>
this is because i want to return the links but only the links frown


new username: tidy_trax
#29943 17/06/03 03:43 PM
Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Alias ExtractLink {
If ($pos($2-,href=",0) < $1) return
var %StartPos = $calc($pos($2-,href=",$1) + 6)
var %StartText = $mid($2-,%StartPos,$calc($len($1-) - %StartPos))
var %EndPos = $calc($pos(%StartText,">,1) - 1)
var %Result = $mid($2-,%StartPos,%EndPos)
return %Result
}

/set %ToGet <NOBR><A href="http://www.mirc.com/faq.html">mIRC FAQ</A></NOBR><BR> <NOBR><A href="http://www.mirc.com/cmds.html">Command List</A></NOBR><P>

/echo $ExtractLink(1,%ToGet) - return http://www.mirc.com/faq.html
/echo $ExtractLink(2,%ToGet) - return
http://www.mirc.com/cmds.html


mIRC Chm Help 6.16.0.3 Full Anchored!
#29944 17/06/03 04:52 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
that doesnt work either when i try

sockread %s
//echo -a $linkextract(1,%s)

i think i might just try again when i get better at identifiers
thanx anyway tho smile


new username: tidy_trax

Link Copied to Clipboard