mIRC Home    About    Download    Register    News    Help

Topic Options
#202216 - 17/07/08 11:14 PM Sockets and Forms
WhipLash Offline
Ameglian cow

Registered: 15/07/08
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
=======================

Top
#202217 - 18/07/08 12:00 AM Re: Sockets and Forms [Re: WhipLash]
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top
#202218 - 18/07/08 12:28 AM Re: Sockets and Forms [Re: starbucks_mafia]
WhipLash Offline
Ameglian cow

Registered: 15/07/08
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
=======================

Top
#202220 - 18/07/08 01:00 AM Re: Sockets and Forms [Re: WhipLash]
WhipLash Offline
Ameglian cow

Registered: 15/07/08
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
=======================

Top
#202221 - 18/07/08 02:04 AM Re: Sockets and Forms [Re: WhipLash]
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top
#202238 - 18/07/08 10:21 AM Re: Sockets and Forms [Re: starbucks_mafia]
WhipLash Offline
Ameglian cow

Registered: 15/07/08
Posts: 24
Thanks so much starbucks_mafia.
I got the script working and parsing the right info.

smile
_________________________
=======================
Count WhipLash
Services Administrator
KnightNet
=======================

Top
#202420 - 22/07/08 02:35 AM Re: Sockets and Forms [Re: WhipLash]
Mail Offline
Pikka bird

Registered: 31/08/05
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.

Top
#202425 - 22/07/08 04:56 AM Re: Sockets and Forms [Re: Mail]
genius_at_work Offline
Hoopy frood

Registered: 08/10/05
Posts: 1741
Tab is ascii 9

-genius_at_work

Top