Scraped HTML is not written at the beginning of text file
Currently, I'm scraping the HTML code of a page, and writing it to a text file.
My problem is, why must there be empty spaces or empty lines at the beginning? The HTML codes written to the txt file do not seem to start at the beginning of the text file. This means that the '<' is not located at the position 0 of the txt file.
After a few runs, my HTML is always written a few lines down inside the text file.
Can anyone tell me why?
Below is my code. I'm doing it under Visual C++ .
UINT32 LOG(wstring log, UINT32 flag)
{
wfstream file (LOG_FIL开发者_高级运维E, ios_base::app);
file << log;
file.close();
return 1;
}
My problem is, the HTML code copied to my text file is always down a couple of lines, then will find the '<' tag. What I want is, the HTML's first '<' is written at the position 0 of my text file :)
Below is my code. I'm doing it under Visual C++ .
UINT32 LOG(wstring log, UINT32 flag)
{
if(flag == 0)
{
wfstream file (LOG_FILE, ios_base::app);
if (file.is_open())
{
file << log <<endl;
file.close();
wcout << endl << log << endl;
return 0;
}
else wcout << "\nUnable to open LOG file\n";
return 1;
}
My problem is, the HTML code copied to my text file is always down a couple of lines, then will find the '<' tag. What I want is, the HTML's first '<' is written at the position 0 of my text file :)
精彩评论