Exemplo n.º 1
0
BOOL CLoginDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	SetIcon(hIcon, TRUE);			// 设置大图标
	SetIcon(hIcon, FALSE);			// 设置小图标

	SetClassLong(m_verifyCodePicture.m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND));

	// 初始化token
	CString src = HTTPGet(_T("https://passport.baidu.com/v2/api/?getapi&class=login&tpl=mn&tangram=true"), TRUE, NULL, &m_cookie);
	m_token = GetStringBetween(src, _T("token='"), _T("'"));
	if (m_token == _T("the fisrt two args should be string type:0,1!"))
	{
		src = HTTPGet(_T("https://passport.baidu.com/v2/api/?getapi&class=login&tpl=mn&tangram=true"), TRUE, NULL, &m_cookie);
		m_token = GetStringBetween(src, _T("token='"), _T("'"));
	}

	// 获取验证码
	OnStnClickedStatic4();

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常:  OCX 属性页应返回 FALSE
}
Exemplo n.º 2
0
// 检查更新
CheckUpdateResult CheckUpdate()
{
	static const wregex CHECK_UPDATE_REG(_T("\"fs_id\":(\\d+),\"path\":\"\\\\/\\\\u6211\\\\u7684\\\\u5206\\\\u4eab\\\\/\\\\u767e")
										 _T("\\\\u5ea6\\\\u8d34\\\\u5427\\\\u76f8\\\\u5173\\\\/\\\\u8d34\\\\u5427\\\\u7ba1\\\\u7")
										 _T("406\\\\u5668.zip\",\"server_filename\":\"\\\\u8d34\\\\u5427\\\\u7ba1\\\\u7406\\\\u5")
										 _T("668.zip\".*?\"server_ctime\":(\\d+),"));
	CString src = HTTPGet(_T("http://pan.baidu.com/share/list?channel=chunlei&clienttype=0&web=1&num=100&page=1&dir=%2F%E6%88%91")
						  _T("%E7%9A%84%E5%88%86%E4%BA%AB%2F%E7%99%BE%E5%BA%A6%E8%B4%B4%E5%90%A7%E7%9B%B8%E5%85%B3&uk=436464474&")
						  _T("shareid=497149087"), FALSE);
	std::wcmatch res;
	if (!std::regex_search((LPCTSTR)src, res, CHECK_UPDATE_REG))
		return UPDATE_FAILED_TO_GET_FILE_ID;

	// 文件ID
	CString fs_id = res[1].str().c_str();

	// 上传时间戳
	CString server_ctime = res[2].str().c_str();
	time_t tServer_ctime = _ttoi64(server_ctime);
	tm tmServer_ctime;
	localtime_s(&tmServer_ctime, &tServer_ctime);
	// 上传时间
	CString time;
	time.Format(_T("%02d-%02d-%02d"), tmServer_ctime.tm_year % 100, tmServer_ctime.tm_mon + 1, tmServer_ctime.tm_mday);
	if (time == UPDATE_CURRENT_VERSION)
		return UPDATE_NO_UPDATE;

	if (AfxMessageBox(_T("最新版本") + time + _T(",是否更新?"), MB_ICONQUESTION | MB_YESNO) == IDNO)
		return UPDATE_HAS_UPDATE;

	static const TCHAR TIME_STAMP_LEFT[] = _T("yunData.TIMESTAMP = \"");
	static const TCHAR TIME_STAMP_RIGHT[] = _T("\"");
	static const TCHAR SIGN_LEFT[] = _T("yunData.SIGN = \"");
	static const TCHAR SIGN_RIGHT[] = _T("\"");
	static const TCHAR BDSTOKEN_LEFT[] = _T("yunData.MYBDSTOKEN = \"");
	static const TCHAR BDSTOKEN_RIGHT[] = _T("\"");
	static const TCHAR DLINK_LEFT[] = _T("\"dlink\":\"");
	static const TCHAR DLINK_RIGHT[] = _T("\"");
	src = HTTPGet(UPDATE_URL, FALSE);
	CString timeStamp = GetStringBetween(src, TIME_STAMP_LEFT, TIME_STAMP_RIGHT);
	CString sign = GetStringBetween(src, SIGN_LEFT, SIGN_RIGHT);
	CString bdstoken = GetStringBetween(src, BDSTOKEN_LEFT, BDSTOKEN_RIGHT);
	CString url;
	url.Format(_T("http://pan.baidu.com/api/sharedownload?sign=%s&timestamp=%s&bdstoken=%s&channel=chunlei")
			   _T("&clienttype=0&web=1&app_id=250528"), sign, timeStamp, bdstoken);
	src = HTTPPost(url, _T("encrypt=0&product=share&uk=436464474&primaryid=497149087&fid_list=%5B") + fs_id + _T("%5D"), FALSE);

	// 文件下载链接
	CString dlink = GetStringBetween(src, DLINK_LEFT, DLINK_RIGHT);
	if (dlink == _T(""))
		return UPDATE_FAILED_TO_GET_LINK;

	dlink.Replace(_T("\\/"), _T("/"));
	ShellExecute(NULL, _T("open"), dlink, NULL, NULL, SW_NORMAL);
	AfxMessageBox(_T("下载后解压并覆盖旧版本文件,可保留当前设置"), MB_ICONINFORMATION);
	return UPDATE_HAS_UPDATE;
}
Exemplo n.º 3
0
void Matchmaker::GetMOTD()
{
#ifdef DLLSAMPLE
	WONIPAddress proxyServer;
	WONIPAddressSetFromStringAndPort(&proxyServer, ADDR_MOTDSERVER, PORT_MOTDSERVER);
	WONError aError = WONHTTPGetFile(&proxyServer, ADDR_MOTDSERVER, PORT_MOTDSERVER, "/motd/sample/motd.txt", "motd.txt", NULL, NULL, TRUE, NULL, NULL, gRequestTimeout);
#else
	Error aError = HTTPGet(ADDR_MOTDSERVER, PORT_MOTDSERVER, "/motd/sample/motd.txt", "motd.txt", NULL, NULL, true, NULL, NULL, gRequestTimeout, false);
#endif // DLLSAMPLE

	switch (aError)
	{
		case StatusCommon_Success:
		{
			struct stat aStatStruct;
			stat("motd.txt", &aStatStruct);
			char timebuf[22];
			strftime(timebuf, 22, "%b %d, %Y %H:%M:%S", localtime(&aStatStruct.st_mtime));
			OutputStringF("Message of the Day (%s)", timebuf);
			OutputFile("motd.txt");
			break;
		}
		default:
			OutputError("Failed to download Message of the Day", aError);
	}
}
Exemplo n.º 4
0
int HTTPDownload(char *URL,char *Login,char *Password, STREAM *S)
{
STREAM *Con;
Con=HTTPGet(URL,Login,Password);
if (! Con) return(FALSE);
HTTPCopyToSTREAM(Con, S);
return(TRUE);
}
Exemplo n.º 5
0
char *GetMatches(char *buffer, size_t len)
{
	char url[256];

	memset(url, 0, sizeof(url));
	snprintf(url, sizeof(url)-1, "http://%s%s%s/", SERVER_ADDR, URL_API_VERSION, URL_MATCHES);
	HTTPGet(url, SERVER_ADDR, SERVER_PORT, buffer, len);
	return buffer;
}
Exemplo n.º 6
0
void Matchmaker::GetPatch()
{
#ifdef DLLSAMPLE
	WONIPAddress proxyServer;
	WONIPAddressSetFromStringAndPort(&proxyServer, ADDR_PATCHSERVER, PORT_PATCHSERVER);
	WONHTTPGetFile(&proxyServer, ADDR_PATCHSERVER, PORT_PATCHSERVER, "SamplePatch.txt", "SamplePatch.txt", NULL, NULL, true, PatchProgressCallback, NULL, gRequestTimeout);
#else
	HTTPGet(ADDR_PATCHSERVER, PORT_PATCHSERVER, "SamplePatch.txt", "SamplePatch.txt", NULL, NULL, true, (ProgressCallback)PatchProgressCallback, NULL, gRequestTimeout, true, (void(*)(Error))PatchDownloadCallback);
#endif // DLLSAMPLE
}
Exemplo n.º 7
0
// 取用户发的帖子ID
CString GetPIDFromUser(const CString& userName)
{
	CString src = HTTPGet(_T("http://tieba.baidu.com/f/search/ures?ie=utf-8&kw=") + g_encodedForumName + _T("&qw=&rn=10&un=") 
		+ userName + _T("&only_thread=&sm=1&sd=&ed=&pn=1"), FALSE);
	if (src == NET_TIMEOUT_TEXT)
		return NET_TIMEOUT_TEXT;
	CString pid = GetStringBetween(src, _T("<div class=\"s_post\">"), _T("target=\"_blank\" >"));
	pid = GetStringBetween(pid, _T("?pid="), _T("&"));
	return pid;
}
Exemplo n.º 8
0
// 取主题列表
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;
}
Exemplo n.º 9
0
// 取用户名
void CLoginDlg::GetLoginUserName()
{
	CString src = HTTPGet(_T("http://tieba.baidu.com/f?ie=utf-8&kw=%D2%BB%B8%F6%BC%AB%C6%E4%D2%FE%C3%D8%D6%BB%D3%D0")
						  _T("xfgryujk%D6%AA%B5%C0%B5%C4%B5%D8%B7%BD"), TRUE, NULL, &m_cookie);
	CString tmp;
	std::wcmatch res;
	if (std::regex_search((LPCTSTR)(tmp = GetStringBetween(src, _T("PageData.user"), _T("}"))), res, USER_NAME_REG))
		m_userName = JSUnescape(res[3].str().c_str());
	if (m_userName == _T(""))
		WriteString(src, _T("login_forum.txt"));
}
Exemplo n.º 10
0
// 取楼中楼列表
void GetLzls(const CString& tid, const CString& page, vector<PostInfo>& posts, vector<PostInfo>& lzls)
{
	time_t timestamp;
	time(&timestamp);
	CString url;
	url.Format(_T("http://tieba.baidu.com/p/totalComment?t=%I64d&tid=%s&fid=%s&pn=%s&see_lz=0"), timestamp, tid, g_forumID, page);
	CString src = HTTPGet(url, FALSE, &g_stopScanFlag);
	//WriteString(src, _T("lzl.txt"));
	CStringArray splitedSrc; // 0楼中楼,1用户
	SplitString(splitedSrc, src, _T("\"user_list\":{"));
	lzls.clear();
	if (splitedSrc.GetSize() != 2)
		return;

	// 遍历用户采集头像哈希
	CStringArray users;
	SplitString(users, splitedSrc[1], LZL_USER_SPLIT);
	map<CString, CString> portrait;
	for (int i = 1; i < users.GetSize(); i++)
	{
		CString id = JSUnescape(GetStringBefore(users[i], LZL_USER_NAME_RIGHT));
		portrait[id] = GetStringBetween(users[i], LZL_USER_PORTRAIT_LEFT, LZL_USER_PORTRAIT_RIGHT);
	}

	// 遍历楼层
	int iLzls = 0;
	for (std::regex_iterator<LPCTSTR> it((LPCTSTR)splitedSrc[0], (LPCTSTR)splitedSrc[0] + splitedSrc[0].GetLength(), LZL_FLOOR_REG), end; it != end; it++)
	{
		// 查找该层楼层
		CString pid = (*it)[1].str().c_str(); // 该层PID
		CString floor;
		for (PostInfo post : posts)
		if (post.pid == pid)
		{
			floor = post.floor;
			break;
		}

		// 遍历该层楼中楼
		CStringArray rawLzls;
		SplitString(rawLzls, (*it)[2].str().c_str(), LZL_SPLIT);
		lzls.resize(lzls.size() + rawLzls.GetSize() - 1);
		for (int iRawLzls = 1; iRawLzls < rawLzls.GetSize(); iRawLzls++, iLzls++)
		{
			lzls[iLzls].pid = GetStringBetween(rawLzls[iRawLzls], LZL_PID_LEFT, LZL_PID_RIGHT);
			lzls[iLzls].floor = floor;
			lzls[iLzls].author = JSUnescape(GetStringBetween(rawLzls[iRawLzls], LZL_AUTHOR_LEFT, LZL_AUTHOR_RIGHT));
			lzls[iLzls].authorID = GetStringBetween(rawLzls[iRawLzls], LZL_AUTHOR_ID_LEFT, LZL_AUTHOR_ID_RIGHT);
			lzls[iLzls].authorPortrait = portrait[lzls[iLzls].author];
			lzls[iLzls].content = HTMLUnescape(JSUnescape(GetStringBetween(rawLzls[iRawLzls], LZL_CONTENT_LEFT, LZL_CONTENT_RIGHT)));
		}
	}
}
Exemplo n.º 11
0
// 取帖子列表
GetPostsResult GetPosts(const CString& tid, const CString& _src, const CString& page, vector<PostInfo>& posts, vector<PostInfo>& lzls)
{
	CString src = _src != _T("") ? _src : HTTPGet(_T("http://tieba.baidu.com/p/") + tid + _T("?pn=") + page, FALSE, &g_stopScanFlag);
	if (src == NET_STOP_TEXT)
		return GET_POSTS_STOP;
	if (src == NET_TIMEOUT_TEXT)
		return GET_POSTS_TIMEOUT;

	CStringArray rawPosts;
	SplitString(rawPosts, src, POST_SPLIT);
	if (rawPosts.GetSize() < 2)
		return GET_POSTS_DELETED;

	posts.resize(rawPosts.GetSize() - 1);
	for (int iRawPosts = 1, iPosts = 0; iRawPosts < rawPosts.GetSize(); iRawPosts++, iPosts++)
	{
		posts[iPosts].pid = GetStringBetween(rawPosts[iRawPosts], POST_PID_LEFT, POST_PID_RIGHT);
		posts[iPosts].floor = GetStringBetween(rawPosts[iRawPosts], POST_FLOOR_LEFT, POST_FLOOR_RIGHT);
		posts[iPosts].author = JSUnescape(GetStringBetween(rawPosts[iRawPosts], POST_AUTHOR_LEFT, POST_AUTHOR_RIGHT));
		posts[iPosts].authorID = GetStringBetween(rawPosts[iRawPosts], POST_AUTHOR_ID_LEFT, POST_AUTHOR_ID_RIGHT);
		posts[iPosts].authorPortrait = GetStringBetween(rawPosts[iRawPosts], POST_AUTHOR_PORTRAIT_LEFT, POST_AUTHOR_PORTRAIT_RIGHT);
		//posts[iPosts].content = GetStringBetween(rawPosts[iRawPosts], POST_CONTENT_LEFT, POST_CONTENT_RIGHT);

		int left = rawPosts[iRawPosts].Find(POST_CONTENT_LEFT) + _tcslen(POST_CONTENT_LEFT);
		left = rawPosts[iRawPosts].Find(_T(">"), left) + 1;
		// 去掉首空格
		while (left < rawPosts[iRawPosts].GetLength() && rawPosts[iRawPosts][left] == _T(' '))
			left++;
		int right = rawPosts[iRawPosts].Find(POST_CONTENT_RIGHT, left + 1);
		// CString不支持反向查找字符串?
		posts[iPosts].content = rawPosts[iRawPosts].Mid(left, right - left);
		LPCTSTR pos = StrRStrI(posts[iPosts].content, NULL, _T("</div>"));
		if (pos != NULL)
		{
			right = ((DWORD)pos - (DWORD)(LPCTSTR)posts[iPosts].content) / sizeof(TCHAR)-1;
			// 去掉尾空格
			while (right >= 0 && posts[iPosts].content[right] == _T(' '))
				right--;
			posts[iPosts].content = posts[iPosts].content.Left(right + 1);
		}
		// 签名档
		posts[iPosts].content += _T("\r\n") + GetStringBetween2(rawPosts[iRawPosts], POST_SIGN_LEFT, POST_SIGN_RIGHT);

		//OutputDebugString(_T("\n"));
		//OutputDebugString(rawPosts[iRawPosts]);
		//OutputDebugString(_T("\n----------------------------------"));
	}

	GetLzls(tid, page, posts, lzls);

	return GET_POSTS_SUCCESS;
}
Exemplo n.º 12
0
//Still trying to figure this out
void YoutubeLogin(char *Username, char *Password)
{
STREAM *S;
char *Tempstr=NULL;

Tempstr=MCopyStr(Tempstr,"https://www.google.com/accounts/ServiceLoginAuth?service=youtube&Email=",Username,"&Passwd=",Password,"&signIn=Sign in","&continue=http://www.youtube.com/signin?action_handle_signin=true&next=",NULL);
//S=HTTPGet("https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true");

S=HTTPGet(Tempstr,"","");
Tempstr=STREAMReadLine(Tempstr,S);
while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
fprintf(stderr,"%s\n",Tempstr);
Tempstr=STREAMReadLine(Tempstr,S);
}

DestroyString(Tempstr);
}
Exemplo n.º 13
0
// 更换验证码
void CLoginDlg::OnStnClickedStatic4()
{
	CString src = HTTPGet(_T("https://passport.baidu.com/v2/?reggetcodestr&token=") + m_token + _T("&tpl=mn&apiver=v3&tt=1374720914453&callback=bd__cbs__hb302a"), TRUE, NULL, &m_cookie);
	m_verifyStr = GetStringBetween(src, _T("\"verifyStr\" : \""), _T("\""));
	
	// 下载图片
	unique_ptr<BYTE[]> buffer;
	ULONG size;
	HTTPGetRaw(_T("https://passport.baidu.com/cgi-bin/genimage?") + m_verifyStr, &buffer, &size, TRUE, NULL, &m_cookie);
	if (buffer == NULL)
	{
		AfxMessageBox(_T("获取验证码图片失败!"), MB_ICONERROR);
		return;
	}

	ReadImage(buffer.get(), size, m_verifyImage);

	// 显示图片
	m_verifyCodePicture.Invalidate();
}
Exemplo n.º 14
0
int CopyURL(HTTPSession *Session, char *From, char *To)
{
char *Tempstr=NULL, *Host=NULL, *PortStr=NULL, *FromPath=NULL, *ToPath=NULL, *User=NULL, *Password=NULL;
int RetVal=EFAULT;
STREAM *In=NULL, *Out=NULL;

ParseURL(To, &Tempstr, &Host, &Tempstr, NULL, NULL, &ToPath, NULL);

if ((access(ToPath,F_OK)==0) && (! (Session->Flags & SESSION_OVERWRITE))) RetVal=EEXIST;

//If the TO Host is local
if (IsLocalHost(Session,Host))
{
  ParseURL(From, &Tempstr, &Host, &PortStr, &User, &Password, &FromPath, NULL);

	if (! IsLocalHost(Session,Host)) 
	{
			In=HTTPGet(From,User,Password);
			if (In) Out=STREAMOpenFile(ToPath,SF_CREAT|SF_WRONLY|SF_TRUNC);
			if (Out) RetVal=STREAMSendFile(In, Out, 0, SENDFILE_KERNEL | SENDFILE_LOOP);
			STREAMClose(In);
			STREAMClose(Out);
	}
	else RetVal=CopyLocalItem(FromPath, ToPath);
}

DestroyString(User);
DestroyString(Password);
DestroyString(Tempstr);
DestroyString(Host);
DestroyString(PortStr);
DestroyString(FromPath);
DestroyString(ToPath);

return(RetVal);
}
Exemplo n.º 15
0
/*!
*\overload
*/
bool Sodaq_WifiBee::HTTPGet(const String& server, const uint16_t port,
  const String& URI, const String& headers, uint16_t& httpCode)
{
  return HTTPGet(server.c_str(), port, URI.c_str(), headers.c_str(), httpCode);
}
Exemplo n.º 16
0
UINT AFX_CDECL CDefriendPage::DefriendThread(LPVOID)
{
	// 初始化
	CTiebaManagerDlg* mainDlg = (CTiebaManagerDlg*)AfxGetApp()->m_pMainWnd;
	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	CString sStartPage, sEndPage;
	if (m_instance != NULL)
	{
		m_instance->m_startPageEdit.GetWindowText(sStartPage);
		m_instance->m_endPageEdit.GetWindowText(sEndPage);
	}
	int startPage = _ttoi(sStartPage), endPage = _ttoi(sEndPage);
	if (startPage > endPage)
	{
		int t = startPage;
		startPage = endPage;
		endPage = t;
	}

	// 获取拉黑列表
	int index = 0;
	std::vector<CString> userName, userID;
	for (int page = startPage; page <= endPage; page++)
	{
		if (m_stopFlag)
			break;
		CString state;
		state.Format(_T("采集第%d页"), page);
		if (m_instance != NULL)
			m_instance->m_stateStatic.SetWindowText(state);
		CString url;
		url.Format(_T("http://tieba.baidu.com/bawu2/platform/listMember?ie=utf-8&word=%s&pn=%d"), g_userTiebaInfo.m_encodedForumName, page);
		CString src = HTTPGet(url);
		if (m_stopFlag)
			break;

		CStringArray rawUsers;
		SplitString(rawUsers, src, _T("<tr><td class=\"left_cell\">"));
		if (rawUsers.GetSize() < 2)
		{
			if (src != NET_TIMEOUT_TEXT)
				WriteString(src, _T("defriend.txt"));
			else
				page--;
			continue;
		}

		userName.resize((int)userName.size() + (int)rawUsers.GetSize() - 1);
		userID.resize((int)userID.size() + (int)rawUsers.GetSize() - 1);
		CString tmp;
		for (int i = 1; i < rawUsers.GetSize(); i++, index++)
		{
			userName[index] = tmp = GetStringBetween(rawUsers[i], _T("un=\""), _T("\""));
			userID[index] = tmp = GetStringBetween(rawUsers[i], _T("id=\""), _T("\""));
		}
	}

	// 拉黑
	for (UINT i = 0; i < userName.size(); i++)
	{
		if (m_stopFlag)
			break;
		/*if (g_defriendedUser.find(userName[i]) != g_defriendedUser.end())
			continue;*/
		CString state;
		state.Format(_T("拉黑中,剩余%u"), userName.size() - i - 1);
		if (m_instance != NULL)
			m_instance->m_stateStatic.SetWindowText(state);

		CString code = Defriend(userID[i]);
		if (code != _T("0"))
		{
			CString content;
			content.Format(_T("<font color=red>拉黑 </font>%s<font color=red> 失败!错误代码:%s(%s)</font><a href=")
						   _T("\"df:%s\">重试</a>"), userName[i], code, GetTiebaErrorText(code), userID[i]);
			mainDlg->m_log.Log(content);
		}
		else
		{
			g_userCache.m_defriendedUser->insert(userName[i]);
			mainDlg->m_log.Log(_T("<font color=red>拉黑 </font>") + userName[i]);
		}

		if (i % 20 == 19 && i < userName.size() - 1)
		{
			if (m_instance != NULL)
				m_instance->m_stateStatic.SetWindowText(_T("延迟中"));
			for (int i = 0; i < 400; i++)
			{
				if (m_stopFlag)
					break;
				Sleep(100);
			}
		}
	}

	m_stopFlag = TRUE;
	CoUninitialize();
	if (m_instance != NULL)
	{
		m_instance->m_startPageEdit.EnableWindow(TRUE);
		m_instance->m_endPageEdit.EnableWindow(TRUE);
		m_instance->m_startButton.EnableWindow(TRUE);
		m_instance->m_stopButton.EnableWindow(FALSE);
		m_instance->m_stateStatic.SetWindowText(_T(""));
	}
	return 0;
}