我如何将 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 错误请求服务器:squid/2.7.STABLE9 日期:2012 年 4 月 23 日星期一 14:45:12 GMT 内容类型:text/html 内容长度:3111 X-Squid-Error:ERR_INVALID_URL 0 X-Cache:来自 amssq46.esams.wikimedia.org 的 MISS X-Cache-Lookup:来自 amssq46.esams.wikimedia.org 的无:80 连接:关闭
我需要创建工具来替换 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" ...
我有
脚本应使用包含联系信息的用户代理字符串,否则它们可能会被 IP 阻止,恕不另行通知。