当前位置: 首页>>代码示例>>C++>>正文


C++ HttpClient::GetBinaryFile方法代码示例

本文整理汇总了C++中HttpClient::GetBinaryFile方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpClient::GetBinaryFile方法的具体用法?C++ HttpClient::GetBinaryFile怎么用?C++ HttpClient::GetBinaryFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpClient的用法示例。


在下文中一共展示了HttpClient::GetBinaryFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
								BOOST_LOG_TRIVIAL(trace) << "  > " << SConv( rLink.second );

								int iBTime = 0;
								boost::optional<wstring> sHTML;
								while (++iBTime < iRetryTimes)
								{
									sHTML = mClient.ReadHtml(CheckLink(SConv(rLink.second), pathURL.string()));
									if (sHTML)
									{
										*sHTML = mSite.FilterHTML(*sHTML);
										break;
									}
								}
								if (sHTML)
								{
									if (!bNoDLImage)
									{
										auto vImg = mSite.FindAllImage(*sHTML);
										if (vImg.size() > 0)
										{
											cout << "      Found " << vImg.size() << " images\n";
											size_t uShift = 0;
											for (auto& rImg : vImg)
											{
												string sLink = CheckLink(SConv(rImg.second), pathURL.string());
												auto sFile = HttpClient::GetFilename(sLink);
												if (sFile)
												{
													BOOST_LOG_TRIVIAL(info) <<  "        " << *sFile;
													FS::path sImagePath = sImage / *sFile;

													bool bNeedDownload = true;
													if (FS::exists(sImagePath))
													{
														if (!bOverWrite)
														{
															auto uSize = FS::file_size(sImagePath);
															bNeedDownload = false;
														}
													}

													if (bNeedDownload)
													{
														int iTimes = 0;
														bool bOK = false;
														while (++iTimes < iRetryTimes)
														{
															BOOST_LOG_TRIVIAL(trace) << ".";
															bOK = mClient.GetBinaryFile(sLink, sImagePath.wstring());
															if (bOK)
																break;
														}
														if (bOK)
															BOOST_LOG_TRIVIAL(trace) << "OK";
														else
															BOOST_LOG_TRIVIAL(error) << "Image <" << *sFile << "> download error.";
													}
													else
														BOOST_LOG_TRIVIAL(trace) << "SKIP";

													sHTML->replace(uShift + rImg.first, rImg.second.size(), sImagePath.wstring());
													uShift += sImagePath.wstring().size() - rImg.second.size();
												}
											}
										}
									}
									oFile << ConvertS2T( mSite.GetChapterContent(*sHTML) );
								}
								else
								{
									BOOST_LOG_TRIVIAL(error) << "Can't read the page:" << SConv( rLink.second );
								}
							}
							oFile << "</BODY></HTML>\n";
							#pragma endregion

							oFile.close();
							BOOST_LOG_TRIVIAL(trace) << "  Start Convert";
							PostProcess(fnBook);
							BOOST_LOG_TRIVIAL(trace) << "  Book output finished";
						}
						else
						{
							BOOST_LOG_TRIVIAL(error) << " Can't open the file to output";
						}
					}
					else
					{
						BOOST_LOG_TRIVIAL(trace) << "  Skip this book.";
					}
				}
			}
		}
	}
	catch (exception e)
	{
		BOOST_LOG_TRIVIAL(fatal) << "Fatal error: " << e.what();
	}
	return 0;
}
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的HttpClient::GetBinaryFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。