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
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.
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.
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