⼀个简单⼩说阅读⽹页html,简单版⼩说搜索阅读(64位程
序)
[C++] 纯⽂本查看 复制代码#include "xiaoshuo.h"
#include
HWND xswnd;
#import "C:\\Windows\\SysWOW64\\winhttpcom.dll" no_namespace
IWinHttpRequest* pwin=NULL;
Sedit g_edt,g_jianjieedt,g_textedt;
Slistbox g_pianzhanglist;
char** pppianzhang;//存放⽂章的篇章标题char*数组
char** pplianjie;//存放⽂章的篇章链接char*数组
char* wenzhangzhengwen;//⽂章正⽂
int wenzhangzhengwenlen;//⽂章正⽂长度
wkeWebView miniblinkwindow;//miniblink⽹页句柄
LRESULT __stdcall webproc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp);//miniblink⽹页窗⼝消息⼦类化过程
LONG_PTR webbackcall;
void xianshi();//显⽰⼩说正⽂
void freelease();//销毁IWinHttpRequest对象
void createhtml(int xuhao){
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(bt(),&FindFileData);
if ((hFind=INVALID_HANDLE_VALUE) || !(FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)){ CreateDirectory(bt(),NULL);
}
FindClose(hFind);
char xuhaobuffer[6]={0};
std::string name=bt();
name=name+"\\";
sprintf(xuhaobuffer,"%d",xuhao);
name=name+xuhaobuffer+".html";
//MessageBox(NULL,name.c_str(),"bt",MB_OK);
FILE* ceshi=fopen(name.c_str(),"r");
if(ceshi==NULL){
FILE* hf=fopen(name.c_str(),"wb+");
fwrite(wenzhangzhengwen,wenzhangzhengwenlen,1,hf);
fclose(hf);
}else
fclose(ceshi);
char directory[100]={0};
GetCurrentDirectory(100,directory);
std::string directorystring=directory;
directorystring=directorystring+"\\"+name.c_str();
char* lujing=const_cast(directorystring.c_str());//⽂件路径
wchar_t wlujing[100]={0};
MultiByteToWideChar(CP_ACP,0,lujing,-1,wlujing,100);
//MessageBoxW(NULL,wlujing,L"d",MB_OK);
wkeLoadFileW(miniblinkwindow,wlujing);//wkeLoadFile不能正常加载路径有汉字的⽹页,只能⽤W版函数}
void sousuo(){
if(strcmp("",bt())==0){
MessageBox(NULL,"请输⼊要搜索的⽂章名称","bt",MB_OK);
return;
}
g_pianzhanglist.deleteallstring();
std::string wenzhangname=bt();
wenzhangname="/search.php?q="+wenzhangname;
pwin->Open("GET",wenzhangname.c_str());//这个⽹站⾸页是GBK,搜索页是UTF8编码,坑
pwin->Send();
_variant_t xstext=pwin->ResponseBody;
char* text=(char*)(xstext.parray->pvData);
//char* hh=(char*)(pwin->ResponseBody.parray->pvData);
int len=pwin->ResponseBody.parray->rgsabound[0].cElements;
//char haha[100]={0};
//sprintf(haha,"%d",len);
//MessageBox(NULL,haha,"bt",MB_OK);
int widelen=MultiByteToWideChar(CP_UTF8,0,text,len,NULL,NULL);
wchar_t* pwtext=new wchar_t[widelen+1];
ZeroMemory(pwtext,2*(widelen+1));
MultiByteToWideChar(CP_UTF8,0,text,len,pwtext,widelen);
int ansilen=WideCharToMultiByte(CP_ACP,0,pwtext,widelen,NULL,NULL,NULL,FALSE);
用html设计一个疫情网页代码char* ptext=new char[ansilen+1];
ZeroMemory(ptext,ansilen+1);
WideCharToMultiByte(CP_ACP,0,pwtext,widelen,ptext,ansilen,NULL,FALSE);
delete[] pwtext;
std::regex jianjiepipei("
(.*?)
");//匹配⼩说简介
std::cmatch m;
std::regex_search((const char*)ptext,(const char*)(ptext+ansilen),m,jianjiepipei);//不需要⽤循环反复匹配,只匹配第⼀个就⾏if(strcmp("",const_cast(m.str(1).c_str()))==0){
MessageBox(NULL,"没有到此本⼩说","bt",MB_OK);
return;
}
g_jianjieedt.setbt(const_cast(m.str(1).c_str()));
std::regex lianjiepipei("
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论