私の目的のために Special:Export を使用する方法。アプリから次のヘッダーを送信します。
string request = "POST en.wikipedia.org/w/index.php?title=Special:Export&action=submit HTTP/1.1\r\n"
"Host: en.wikipedia.org\r\n"
"Content-Length: 32\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Connection: close\r\n\r\n"
"catname=&pages=ukraine&curonly=1";
しかし、エラーに関するページが表示されます:
HTTP/1.0 400 Bad Request Server: squid/2.7.STABLE9 Date: Mon, 23 Apr 2012 14:45:12 GMT Content-Type: text/html Content-Length: 3111 X-Squid-Error: ERR_INVALID_URL 0 X-Cache: amssq46.esams.wikimedia.org からの MISS X-Cache-Lookup: amssq46.esams.wikimedia.org:80 からの NONE 接続: 閉じる
翻訳に役立つ inwiki リンクを置き換えるツールを作成する必要があります。そのようなツールがすでに存在することは確かですが、自分でやりたいです。
編集: 私は c++ とソケットを使用します。
編集済み: 新しいリクエスト:
string request = "POST https://en.wikipedia.org/w/index.php?title=Special:Export&action=submit HTTP/1.1\r\n"
//string request = "GET https://en.wikipedia.org/w/index.php?title=Special:Export&pages=ukraine&curonly=1\r\n"
"Host: en.wikipedia.org\r\n"
"User-Agent: MyCoolTool\r\n"
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
"Accept-Language: en-us,en;q=0.5\r\n"
"Accept-Encoding: gzip, deflate\r\n"
"Content-Length: 32\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Connection: close\r\n\r\n"
"catname=&pages=Ukraine&curonly=1";
ページだけを取得しようとすると
string request = "GET http://en.wikipedia.org/wiki/Ukraine\r\n" ...
"User-Agent: YolaTool/0.1\r\n" ...
私は持っている
スクリプトでは、連絡先情報を含む有益な User-Agent 文字列を使用する必要があります。そうしないと、予告なしに IP ブロックされる場合があります。