thegame8311
Technical User
ok, I'm going to try to explain this the best way possible, so here it goes:
I am trying to run URLDownloadToFile, using links from a file, so It would read the first link, process it, save it to a file, read the next link, process it, save it to the same file.
Problem is that even if i put it in a function, that is called from a loop, that it will process the first link, save all the info that I want, then overwrite the info from the first link with the second link, then go back and process the first link again and over write the second link info:
here is the code:
here is the function that is supposed to handle the link:
I am trying to run URLDownloadToFile, using links from a file, so It would read the first link, process it, save it to a file, read the next link, process it, save it to the same file.
Problem is that even if i put it in a function, that is called from a loop, that it will process the first link, save all the info that I want, then overwrite the info from the first link with the second link, then go back and process the first link again and over write the second link info:
here is the code:
Code:
string line;
ifstream flink;
ifstream fin;
ifstream fin2;
ofstream fout;
ofstream fout2;
std::string plink;
string start = "profile\"";
string end = "</a>";
string tbod = "<tbody>";
string etbod = "</tbody>";
string slink = "<a href=";
bool tbody = false;
string Name;
flink.open("playerlinks.txt");
std::string str; LPCSTR lpcstr = str.c_str();
getline(flink, plink);
while(flink)
{
cout << (LPCSTR)plink.c_str() << endl;
ProcsLink(plink);
{
//Some other code for saving info
fout2 << nPname << " ";
fout2 << ntname;
fout2 << endl;
}
flink >> plink;
cout << "hi" << endl;
system("PAUSE");
//return 0;
}
}
here is the function that is supposed to handle the link:
Code:
void ProcsLink(string plink)
{
string line;
ifstream fin;
ofstream fout;
string start = "profile\"";
string end = "</a>";
string tbod = "<tbody>";
string etbod = "</tbody>";
string slink = "<a href=";
bool tbody = false;
string Name;
HRESULT hr = URLDownloadToFile(NULL, (LPCSTR)plink.c_str(), _T("test2.txt"), 0, NULL);
fin.open("test2.txt");
fout.open("test3.txt");
while(fin.good())
{
getline(fin, line);
if(line.find(tbod) != string::npos)
{
tbody = true;
}
if(line.find(etbod) != string::npos)
{
tbody = false;
}
if(line.find(start) != string::npos && tbody == true)
{
fout << line;
}
else if(line.find(slink) != string::npos && tbody == true)
{
fout << line;
fout << endl;
}
}
}