怎么获取网站的源码

xiaomi0034 2012-04-07 05:31:02
怎么实现获取一个网站的源码,求指点,我是菜鸟,希望能给出具体一点的步骤.急.....
...全文
619 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaomi0034 2012-04-18
  • 打赏
  • 举报
回复
你们的代码都很OK,谢谢
tufei2963 2012-04-17
  • 打赏
  • 举报
回复
chrome 浏览器 按F12
xiaomi0034 2012-04-17
  • 打赏
  • 举报
回复
需求是:通过获取像(右键->查看源文件这个能看到的源码)的内容,分析源文件里面的所有链接。如果是发送http请求道服务器,那发送http请求信息是什么呢?求指点。
x363635334 2012-04-17
  • 打赏
  • 举报
回复
发个MFC版的批量搜索的,CString类的好处是够装百度的html文本了

#include "stdafx.h"
#include<iostream> //for std::cout
using namespace std; //for std::cout
#include <afxwin.h> //AfxGetApp()
#include <afxinet.h> //CInternetSession,CHttpFile
CWinApp 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();
}
RabbitLBJ 2012-04-17
  • 打赏
  • 举报
回复

#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;
}
luciferisnotsatan 2012-04-16
  • 打赏
  • 举报
回复
想学习如何做网站,网上有很多例子
luciferisnotsatan 2012-04-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

怎么通过编程实现?
[/Quote]
右键->查看源文件这个能看到的源码,实际就是http发过来的东西。代码里你发送http请求,然后收到的就是了。
想看真正的源码,把那网站收购了就能看到。
evencoming 2012-04-16
  • 打赏
  • 举报
回复
请参考:rfc2616
xiaomi0034 2012-04-16
  • 打赏
  • 举报
回复
怎么通过编程实现?
卡卡_苏米 2012-04-16
  • 打赏
  • 举报
回复
编程实现? 这个你看一下HTML文件解析,
DeveloperSimon 2012-04-07
  • 打赏
  • 举报
回复
右键->查看源文件 或者 菜单栏上的查看->查看源文件

64,647

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧