mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 106
L
Vogon poet
OP Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
I am fooling around with Wikipedia, looking at different ways to use the WikiMedia API.
Here is the sockopen and sockread code I am using to get the wikipedia page for MYTH
Code:
on *:sockopen:w3: {
  sockwrite -n $sockname GET /w/index.php?title=Myth&action=raw HTTP/1.1 
  sockwrite -n $sockname User-Agent: xxxxx 
  sockwrite -n $sockname Host: en.wikipedia.org 
  sockwrite -n $sockname $crlf
}

on *:sockread:w3: {
  if ($sockerr > 0) {
    return
  }
  :nextread
  sockread %temp
  if ($sockbr == 0) {
    return
  }
  if %temp == $null {
    %temp = -
  }
  aline @w3 %temp $chr(160)
  goto nextread
}
and here is what the @w3 window receives.
Quote:
HTTP/1.0 200 OK
Date: Tue, 01 Feb 2011 23:29:09 GMT
Server: Apache
Cache-Control: public, s-maxage=0, max-age=2678400
Last-Modified: Tue, 28 Sep 2010 09:51:38 GMT
Vary: Accept-Encoding
Content-Length: 23
Content-Type: text/x-wiki; charset=UTF-8
X-Cache: MISS from sq78.wikimedia.org
X-Cache-Lookup: HIT from sq78.wikimedia.org:3128
X-Cache: MISS from sq62.wikimedia.org
X-Cache-Lookup: MISS from sq62.wikimedia.org:80
Connection: close
-


However, Wireshark shows that wikipedia is sending more than my code extracts. Note the final line.
Quote:
GET /w/index.php?title=Myth&action=raw HTTP/1.1
User-Agent: xxxxx
Host: en.wikipedia.org

HTTP/1.0 200 OK
Date: Tue, 01 Feb 2011 23:29:09 GMT
Server: Apache
Cache-Control: public, s-maxage=0, max-age=2678400
Last-Modified: Tue, 28 Sep 2010 09:51:38 GMT
Vary: Accept-Encoding
Content-Length: 23
Content-Type: text/x-wiki; charset=UTF-8
X-Cache: MISS from sq78.wikimedia.org
X-Cache-Lookup: HIT from sq78.wikimedia.org:3128
X-Cache: MISS from sq62.wikimedia.org
X-Cache-Lookup: MISS from sq62.wikimedia.org:80
Connection: close

#REDIRECT [[Mythology]]

If I post en.wikipedia.org/w/index.php?title=Myth&action=raw directly into my web browser, wikipedia sends me a file named index.php consisting of "#REDIRECT [[Mythology]]".

My question is, how do I capture the redirect that Wireshark shows me that wikipedia is sending.

cheers




-
Just because it never happened doesn't mean it isn't true.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You'll want to /sockread -f, otherwise mIRC won't read in lines not ending in a <crlf>, which I assume is the case for that last line.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Feb 2003
Posts: 106
L
Vogon poet
OP Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
Bingo!
And I know, I know ... read the help file.


cheeers


-
Just because it never happened doesn't mean it isn't true.

Link Copied to Clipboard