Javascript 下载带有C++;

Javascript 下载带有C++;,javascript,c++,html,wininet,Javascript,C++,Html,Wininet,我终于成功地使用wininet库将网页下载到磁盘。我目前使用的是以下C++代码: #include <windows.h> #include <wininet.h> #include <stdio.h> #include <fstream> #include <cstring> #define SIZE 128 int main(int argc, char ** argv)

我终于成功地使用wininet库将网页下载到磁盘。我目前使用的是以下C++代码:

    #include <windows.h>
    #include <wininet.h>
    #include <stdio.h>
    #include <fstream>
    #include <cstring>

    #define SIZE 128


    int main(int argc, char ** argv)

    {

    HINTERNET Initialize,Connection,File;
    DWORD dwBytes;

    char ch;
    Initialize = InternetOpen("HTTPGET",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);

    Connection = InternetConnect(Initialize,argv[1],INTERNET_DEFAULT_HTTP_PORT,
    NULL,NULL,INTERNET_SERVICE_HTTP,0,0);


    File = HttpOpenRequest(Connection,NULL,"/index.html",NULL,NULL,NULL,0,0);
    if(HttpSendRequest(File,NULL,0,NULL,0))
    {
        std::ofstream webSource;
        webSource.open(strcat(argv[1], "__.html"));
        while(InternetReadFile(File,&ch,1,&dwBytes))
        {
            if(dwBytes != 1)break;
            webSource << ch;
        }
        webSource.close();
    }

    InternetCloseHandle(File);
    InternetCloseHandle(Connection);
    InternetCloseHandle(Initialize);

    return 0;
}
#包括
#包括
#包括
#包括
#包括
#定义大小128
int main(int argc,字符**argv)
{
网络初始化、连接、文件;
双字双字节;
char ch;
Initialize=InternetOpen(“HTTPGET”,INTERNET\u OPEN\u TYPE\u DIRECT,NULL,NULL,0);
连接=INTERNET连接(初始化,argv[1],INTERNET\u默认\u HTTP\u端口,
NULL,NULL,互联网服务(HTTP,0,0);
File=HttpOpenRequest(连接,NULL,“/index.html”,NULL,NULL,NULL,0,0);
if(HttpSendRequest(文件,NULL,0,NULL,0))
{
流web源的std::;
open(strcat(argv[1],“__.html”);
while(InternetReadFile(文件,&ch,1,&dwBytes))
{
如果(dwBytes!=1)中断;
webSource该
标记用于将客户端(通常是浏览器)重定向到另一个URL。您的代码没有响应该URL,因此您所看到的只是初始页面

这:


告诉客户端,在零秒延迟后,应该获取页面“index.jsp”。如果从URL开始,您可能会看到发生什么


立即重定向到index.jsp。

很好,我也得到了相同的“网页”我从www.rottentomotoos.com上下载过。但是现在,当我尝试下载页面时,我什么也没有得到。为什么?有什么解决方案,建议吗?我在下载时遇到了403错误。我建议在开发自己的软件时,用curl或wget之类的工具尝试一下。它对我来说很好:hRequest=HttpOpenRequest(hConnect,L“get”,L)“/index.jsp”,L“HTTP/1.1”,NULL,NULL,INTERNET_标志_重新加载| INTERNET_标志_现有_连接,0);您能指出如何在我的代码中插入此语句吗?谢谢。
<HEAD><TITLE>Flixster</TITLE>

<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">

<meta http-equiv="refresh" content="0;url=index.jsp">

<!--

<meta http-equiv="refresh" content="0;url=maintenance.html">

-->

</HEAD>



<BODY>

</body>

</html>
<meta http-equiv="refresh" content="0;url=index.jsp">