本文整理汇总了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;
}