print?根據某一類的url鏈接有相同的開頭,以及相同的位置結束來截取字符串,從而取得其href
根據某一類的url鏈接有相同的開頭,以及相同的位置結束來截取字符串,從而取得其href
[cpp] void CzcfxDlg::OnBnClickedBtngeturls()
{
// TODO: 在此添加控件通知處理程序代碼
g_Log.print(LogLevel_Info,"[info] get url start.\n");
CFile f;
//let's open file and read it into CString (u can use any buffer to read though
if (f.Open("klsf.txt", CFile::modeRead|CFile::shareDenyNone)) {
//m_wndLinksList.ResetContent();
CString csWholeFile;
f.Read(csWholeFile.GetBuffer(f.GetLength()), f.GetLength());
csWholeFile.ReleaseBuffer(f.GetLength());
f.Close();
int first=0;
CString strStart="href=\"/soccer/match";
int end=0;
CString strEnd ="target=\"_blank\"";
while(csWholeFile.Find(strStart,first)>end)
{
CString strUrl=GetVlue(first,first,csWholeFile,strStart,strEnd);
void CzcfxDlg::OnBnClickedBtngeturls()
{
// TODO: 在此添加控件通知處理程序代碼
g_Log.print(LogLevel_Info,"[info] get url start.\n");
CFile f;
//let's open file and read it into CString (u can use any buffer to read though
if (f.Open("klsf.txt", CFile::modeRead|CFile::shareDenyNone)) {
//m_wndLinksList.ResetContent();
CString csWholeFile;
f.Read(csWholeFile.GetBuffer(f.GetLength()), f.GetLength());
csWholeFile.ReleaseBuffer(f.GetLength());
f.Close();
int first=0;
CString strStart="href=\"/soccer/match";
int end=0;
CString strEnd ="target=\"_blank\"";
while(csWholeFile.Find(strStart,first)>end)
{
CString strUrl=GetVlue(first,first,csWholeFile,strStart,strEnd);
[cpp] view plaincopyprint? }
}
}
}
}
}[cpp]
[cpp] <PRE class=cpp name="code">CString CzcfxDlg::GetVlue(int &end,int last,CString str,CString startStr,CString endStr)
{
int start =str.Find(startStr,last);
end=str.Find(endStr,start);
g_Log.print(LogLevel_Info,"[info] 位置 start=%d,end=%d,last=%d.\n",start,end,last);
int iLen1=start+startStr.GetLength();
int iLen2=end-start-startStr.GetLength();
CString result=str.Mid(iLen1,iLen2);
g_Log.print(LogLevel_Info,"[info] 名字為 %s.\n",result);
return result;
}
</PRE><BR>
<PRE></PRE>
<PRE></PRE>