mIRC Home    About    Download    Register    News    Help

Print Thread
Sockets and Forms #202216 17/07/08 10:14 PM
Joined: Jul 2008
Posts: 24
W
WhipLash Offline OP
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Jul 2008
Posts: 24
Hey all,

I'v enever really bothered with sockets before, and decided i'd like to give it a bash. My first attempt involves a translator site.

The question i got is, how do i insert $1- into the form, and search for it, if the search info isnt in the url afterwards?


=======================
Count WhipLash
Services Administrator
KnightNet
=======================
Re: Sockets and Forms [Re: WhipLash] #202217 17/07/08 11:00 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
It's probably using the HTTP POST method. You'll have to check out the <form> in the source to figure out what variables are given by the <input> tags' name attributes. Then send the variables as the message body in the manner described in the link I've given you.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Sockets and Forms [Re: starbucks_mafia] #202218 17/07/08 11:28 PM
Joined: Jul 2008
Posts: 24
W
WhipLash Offline OP
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Jul 2008
Posts: 24
Thanks, I'll tinker a bit. But im sure you'll hear from me again. lol.

I don't think i started with the easiest of scripts regarding sockets


=======================
Count WhipLash
Services Administrator
KnightNet
=======================
Re: Sockets and Forms [Re: WhipLash] #202220 18/07/08 12:00 AM
Joined: Jul 2008
Posts: 24
W
WhipLash Offline OP
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Jul 2008
Posts: 24
Nope, no luck for me. *sigh*

Here's the site i'm trying to get the script working with:
Freedict

And as for the links and their values, this is what i thought it was, but its wrong:
http://www.freedict.com/onldict/onldict.php?search= $+ $1 $+ &exact=true&from=english&to=latin&fname=eng2lat1&back=lat.html

Do i have to include all that stuff from the link you gave me on POSTs using the sockwrite?


=======================
Count WhipLash
Services Administrator
KnightNet
=======================
Re: Sockets and Forms [Re: WhipLash] #202221 18/07/08 01:04 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Because you're using the POST method the variables shouldn't be appended to the URL, instead they should be URL encoded and sent after the headers as the message body. The length of all those variables in a string (ie. the message body length) should be sent as the Content-Length header. The Content-Type header should be application/x-www-form-urlencoded (unless the form explicitly provides a different one, which that form doesn't). The From header isn't necessary. The User-Agent header isn't technically necessary but some CGI scripts don't like it if you don't provide one. You should also specify Host and Referer headers to be safe.

Code:
alias urlencode return $replace($regsubex($1,/([^\w\d\x20])/g,% $+ $base($asc(\t),10,16)), $chr(32), +)



; Socket code starts here

var %message = search= $+ $urlencode($1) $+ &max=10&exact=true&from=English&to=Latin&fname=eng2lat1&back=lat.html

sockwrite -n moo POST /onldict/onldict.php HTTP/1.0
sockwrite -n moo Host: www.freedict.com
sockwrite -n moo User-Agent: Anything
sockwrite -n moo Referer: http://www.freedict.com/onldict/lat.html
sockwrite -n moo Content-Type: application/x-www-form-urlencoded
sockwrite -n moo Content-Length: $len(%message)
sockwrite -n moo
sockwrite -t moo %message



Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Sockets and Forms [Re: starbucks_mafia] #202238 18/07/08 09:21 AM
Joined: Jul 2008
Posts: 24
W
WhipLash Offline OP
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Jul 2008
Posts: 24
Thanks so much starbucks_mafia.
I got the script working and parsing the right info.

smile


=======================
Count WhipLash
Services Administrator
KnightNet
=======================
Re: Sockets and Forms [Re: WhipLash] #202420 22/07/08 01:35 AM
Joined: Aug 2005
Posts: 18
M
Mail Offline
Pikka bird
Offline
Pikka bird
M
Joined: Aug 2005
Posts: 18
I am doing something very similar to this, but I am picking out tokens on a web page and storing the data for future use. The problem I am having is There are tabbed spaces in the line I am reading. My question is this, $chr(60) = <, Is there a $chr number for the tab key ? If there is, It would possibly helpful to know what that number is so I can possibly $remove them from that line and get correct token.

Re: Sockets and Forms [Re: Mail] #202425 22/07/08 03:56 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Tab is ascii 9

-genius_at_work