mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2013
Posts: 24
Z
Zabache Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Jun 2013
Posts: 24
This sample page popups right up in my web browser: http://www.kmart.com/tvs-electronics-car-electronics-car-gps-systems/b-1231486124 But my mirc remote script connection is caught up by a 301 redirect...

alias PriceCheck { sockclose PriceCheck | sockopen PriceCheck kmart.com 80 }
alias -l sw { if ($sock($1)) && ($sock($1).status = active) { sockwrite -nt $1- } | else { echo -s * PriceCheck: $sock(PriceCheck).status | .timerrePriceCheck 1 9 PriceCheck } }
on *:sockopen:PriceCheck:{ sw $sockname GET $+(/tvs-electronics-car-electronics-car-gps-systems/b-1231486124 HTTP/1.1,$lf,Host: kmart.com,$str($crlf,2))) }
on *:sockread:PriceCheck:{ sockread -fn &PriceCheck | var %v = $bvar(&PriceCheck,1,$bvar(&PriceCheck,0)).text | echo -s * %v }

* HTTP/1.1 301 Moved Permanently
* Date: Tue, 27 Aug 2013 02:19:23 GMT
* Location: http://www.kmart.com/tvs-electronics-car-electronics-car-gps-systems/b-1231486124
* Content-Length: 289
* Content-Type: text/html; charset=iso-8859-1
*
* <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
* <html><head>
* <title>301 Moved Permanently</title>
* </head><body>
* <h1>Moved Permanently</h1>
* <p>The document has moved <a href="http://www.kmart.com/tvs-electronics-car-electronics-car-gps-systems/b-1231486124">here</a>.</p>
* </body></html>

...please show me how to correct my code to redirect and read the source of the page my browser sees.

Last edited by Zabache; 27/08/13 02:22 AM. Reason: code box too small
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
The host you write needs to be www.kmart.com, not kmart.com (you still open the socket to kmart.com)

Otherwise to handle the 301 you just read the status and location from the response.

Joined: Jun 2013
Posts: 24
Z
Zabache Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Jun 2013
Posts: 24
they reply precisely the same with or without the www. on either or both. their reply is a duplicate of the link I am using, it leads nowhere different. My browser navigates this, wGet navigates and will read their page. an mIRC remote script connection can surely do so as well, but i do not know how... please explain harder if i misunderstood your directions.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
This is what I meant; I tested it and it works. Change in red.

Quote:
alias PriceCheck { sockclose PriceCheck | sockopen PriceCheck kmart.com 80 }
alias -l sw { if ($sock($1)) && ($sock($1).status = active) { sockwrite -nt $1- } | else { echo -s * PriceCheck: $sock(PriceCheck).status | .timerrePriceCheck 1 9 PriceCheck } }
on *:sockopen:PriceCheck:{ sw $sockname GET $+(/tvs-electronics-car-electronics-car-gps-systems/b-1231486124 HTTP/1.1,$lf,Host: www.kmart.com,$str($crlf,2))) }
on *:sockread:PriceCheck:{ sockread -fn &PriceCheck | var %v = $bvar(&PriceCheck,1,$bvar(&PriceCheck,0)).text | echo -s * %v }


On a somewhat unrelated note, you may want to request HTTP/1.0 instead of HTTP/1.1, this will prevent chunked encoding that may cause trouble for saving or parsing.

Last edited by Loki12583; 27/08/13 10:48 PM.
Joined: Jun 2013
Posts: 24
Z
Zabache Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Jun 2013
Posts: 24
thank you for clarifying your position on this, Loki. I had tried that very same fix you www.suggested last night and it did not work, now i try yours and it does work, then i retry mine again and it works also. Must have been something else in my way. Great solution i will keep this and your 1.0ther suggestion in mind for all my connections.


Link Copied to Clipboard