コード例 #1
0
ファイル: TiebaCollect.cpp プロジェクト: CHNhawk/TiebaManager
// 取主题列表
BOOL GetThreads(LPCTSTR forumName, LPCTSTR ignoreThread, vector<ThreadInfo>& threads)
{
	CString src = HTTPGet(_T("http://tieba.baidu.com/f?ie=UTF-8&kw=") + EncodeURI(forumName)
		+ _T("&tp=0&pn=") + ignoreThread + _T("&apage=1"), FALSE, &g_stopScanFlag);

	CStringArray rawThreads;
	SplitString(rawThreads, src, THREAD_SPLIT);
	if (rawThreads.GetSize() < 2)
	{
		if (src != NET_STOP_TEXT && src != NET_TIMEOUT_TEXT)
			WriteString(src, _T("forum.txt"));
		return FALSE;
	}

	int iThreads;
	//// 今日主题
	//CString topic = GetStringBetween(rawThreads[0], TOPIC_LEFT, TOPIC_RIGHT);
	//if (topic != _T(""))
	//{
	//	threads.resize(rawThreads.GetSize());
	//	int pos = topic.Find(TOPIC_TID_LEFT);
	//	threads[0].tid = GetStringBetween(topic, TOPIC_TID_LEFT, TOPIC_TID_RIGHT, pos);
	//	threads[0].reply = GetStringBetween(topic, TOPIC_REPLY_LEFT, TOPIC_REPLY_RIGHT);
	//	threads[0].title = GetStringBetween(topic, TOPIC_TITLE_LEFT, TOPIC_TITLE_RIGHT, pos);
	//	threads[0].preview = GetStringBetween(topic, TOPIC_PREVIEW_LEFT, TOPIC_PREVIEW_RIGHT, pos);
	//	threads[0].author = _T("");

	//	iThreads = 1;
	//}
	//else
	//{
	threads.resize(rawThreads.GetSize() - 1);
	iThreads = 0;
	//}

	// 普通主题
	rawThreads[rawThreads.GetSize() - 1] = GetStringBefore(rawThreads[rawThreads.GetSize() - 1], THREAD_END);
	for (int iRawThreads = 1; iRawThreads < rawThreads.GetSize(); iRawThreads++, iThreads++)
	{
		threads[iThreads].tid = GetStringBetween(rawThreads[iRawThreads], THREAD_TID_LEFT, THREAD_TID_RIGHT);
		threads[iThreads].reply = GetStringBetween(rawThreads[iRawThreads], THREAD_REPLY_LEFT, THREAD_REPLY_RIGHT);
		threads[iThreads].title = HTMLUnescape(GetStringBetween(rawThreads[iRawThreads], THREAD_TITLE_LEFT, THREAD_TITLE_RIGHT));
		threads[iThreads].preview = HTMLUnescape(GetStringBetween(rawThreads[iRawThreads], THREAD_PREVIEW_LEFT, THREAD_PREVIEW_RIGHT))
			+ _T("\r\n") + GetStringBetween2(rawThreads[iRawThreads], THREAD_MEDIA_LEFT, THREAD_MEDIA_RIGHT);
		threads[iThreads].authorID = GetStringBetween(rawThreads[iRawThreads], THREAD_AUTHOR_ID_LEFT, THREAD_AUTHOR_ID_RIGHT);
		threads[iThreads].author = JSUnescape(GetStringBefore(rawThreads[iRawThreads], THREAD_AUTHOR_RIGHT));

		//OutputDebugString(_T("\n"));
		//OutputDebugString(rawThreads[iRawThreads]);
		//OutputDebugString(_T("\n----------------------------------"));
	}

	return TRUE;
}
コード例 #2
0
ファイル: DLGsoap.cpp プロジェクト: a1324yn/zogvm
void CDLGsoap::OnBnClickedButtonEd2k()
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	int i;
	CString str="";
	char tempstr[32]={0};
	long long nid;
	char url[1024]={0};

	if(soapList.size() <=0)
		return ;

	list<struct FILE_SOAP_READ_ST>::iterator beglist;

	// ClearClipboradBuffer();

	for( i=0;i<m_list.GetItemCount();i++)
	{
		if(m_list.GetCheck(i))
		{
			m_list.GetItemText(i,0,tempstr,32);
			sscanf(tempstr,"%I64u",&nid);

			for(beglist=soapList.begin();beglist!=soapList.end();beglist++)
			{
				if(beglist->file_nid == nid)
				{
					if(strlen(beglist->ed2k)>0)
					{
						EncodeURI(beglist->name,url,1024);

						sprintf(beglist->ed2kurl,"ed2k://|file|%s|%I64u|%s|h=%s",url,beglist->filesize,beglist->ed2k,beglist->aich);
						str+=beglist->ed2kurl;
						str+="\r\n";
					}
					break;
				}
			}
		}
	}
	if(str.IsEmpty())
		return ;
	AppendBufferToClipboard(str.GetBuffer(0),str.GetLength());
}
コード例 #3
0
String EncodeURI(const char *str, size_t len)
{
	String rtn;
	EncodeURI(rtn, str, len);
	return rtn;
}
コード例 #4
0
String EncodeURI(const char *str)
{
	String rtn;
	EncodeURI(rtn, str);
	return rtn;
}
コード例 #5
0
ファイル: LoginDlg.cpp プロジェクト: CHNhawk/TiebaManager
// 登录
void CLoginDlg::OnOK()
{
	CString userName, password, verifyCode;
	m_userNameEdit.GetWindowText(userName);
	if (userName == _T(""))
	{
		m_userNameEdit.SetFocus();
		return;
	}
	m_passwordEdit.GetWindowText(password);
	if (password == _T(""))
	{
		m_passwordEdit.SetFocus();
		return;
	}
	m_verifyCodeEdit.GetWindowText(verifyCode);
	if (verifyCode == _T(""))
	{
		m_verifyCodeEdit.SetFocus();
		return;
	}

	EnableWindow(FALSE);

	time_t timestamp;
	time(&timestamp);
	CString data;
	data.Format(_T("staticpage=http%%3A%%2F%%2Fwww.baidu.com%%2Fcache%%2Fuser%%2Fhtml%%2Fv3Jump.html&charset=utf-8&token=%s&tpl=mn")
				_T("&apiver=v3&tt=%I64d&codestring=%s&isPhone=false&safeflg=0&u=http%%3A%%2F%%2Fwww.baidu.com%%2F&username=%s&pass")
				_T("word=%s&verifycode=%s&mem_pass=on&ppui_logintime=35219&callback=parent.bd__pcbs__4y6hex"),
				m_token, timestamp, m_verifyStr, EncodeURI(userName), EncodeURI(password), verifyCode);
	CString result = HTTPPost(_T("https://passport.baidu.com/v2/api/?login"), data, TRUE, NULL, &m_cookie);

	EnableWindow(TRUE);
	if (result == NET_TIMEOUT_TEXT)
	{
		AfxMessageBox(_T("连接超时..."), MB_ICONERROR);
		OnStnClickedStatic4();
		m_verifyCodeEdit.SetWindowText(_T(""));
		return;
	}
	if (!StringIncludes(m_cookie, _T("BDUSS=")))
	{
		WriteString(result, _T("login.txt"));
		AfxMessageBox(_T("登录失败!"), MB_ICONERROR);
		if (userName.Left(1) == _T("1"))
			AfxMessageBox(_T("(不能用手机号哦)"), MB_ICONINFORMATION);
		goto error;
	}

	GetLoginUserName();
	if (m_userName == _T(""))
	{
		AfxMessageBox(_T("获取用户名失败!"), MB_ICONERROR);
		goto error;
	}

	CDialog::OnOK();
	return;

error:
	OnStnClickedStatic4();
	m_verifyCodeEdit.SetWindowText(_T(""));
}