首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

如何获取网站的源码

2012-04-22 
怎么获取网站的源码怎么实现获取一个网站的源码,求指点,我是菜鸟,希望能给出具体一点的步骤.急.....[解决

怎么获取网站的源码
怎么实现获取一个网站的源码,求指点,我是菜鸟,希望能给出具体一点的步骤.急.....

[解决办法]

C/C++ code
#include<windows.h>     #include<wininet.h>     #include<iostream>   #include <tchar.h>  using namespace std;  #pragma comment(lib,"wininet.lib")     int main(){    HINTERNET internetopen;         HINTERNET    internetopenurl;         char buffer[1024 * 16];    DWORD byteread;    BOOL bReadOK ;    internetopen = InternetOpen(/*_T("DownLoadFile")*/NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);         if (internetopen==NULL)         {              cout<<"Internet open failed!"<<endl;             return 1;         }        internetopenurl = InternetOpenUrl(internetopen,_T("http://www.baidu.com"),          NULL,0,INTERNET_FLAG_TRANSFER_ASCII|INTERNET_FLAG_PRAGMA_NOCACHE,0);      //下载的URL      if (internetopenurl==NULL)         {              cout<<"Internet open url failed! error code = "<<GetLastError()<<endl;              return 1;       }         bReadOK = InternetReadFile(internetopenurl,buffer,sizeof(buffer),&byteread);       if(bReadOK == TRUE)    {        buffer[byteread] = '\0';        cout << buffer << endl;        }    cin.get();    return 0;}
[解决办法]
发个MFC版的批量搜索的,CString类的好处是够装百度的html文本了
C/C++ code
#include "stdafx.h"#include<iostream> //for std::coutusing namespace std; //for std::cout#include <afxwin.h> //AfxGetApp()#include <afxinet.h> //CInternetSession,CHttpFileCWinApp theApp;int main(int argc, char* argv[]){    AfxWinInit(GetModuleHandle(NULL),NULL,GetCommandLine(),0);    HWND hWnd=AfxGetApp()->m_pMainWnd->GetSafeHwnd();    CString csURL,csURL1="http://www.baidu.com/_",csURL3=".html",csLine,csText;    CInternetSession mySession;    CHttpFile* pHttpFile;    for(int i=1;i<=344;i++)    {        csText="";        csURL.Format("%s%d%s",csURL1,i,csURL3);        pHttpFile=(CHttpFile*)mySession.OpenURL(csURL);        while( pHttpFile->ReadString(csLine) )            csText+=csLine+"\r\n";        //cout<<csText<<endl;        if(csText.Find("字")!=-1&&csText.Find("字词")==-1)            cout<<i<<endl;    }    pHttpFile->Close();    mySession.Close();} 

热点排行