Knowledge Base Nr: 00175 tvselect.cpp - http://www.swe-kaiser.de

Downloads:

MFC: Fernsehprogramm aus Internet extrahieren und als HTML-Datei speichern

  
#include "../cpp_classes/NetSupport.h"

class CMyNetSupport : public CNetSupport
{
public:
CMyNetSupport() { m_bActive = false; }

virtual int OnLineReceived(char* szLine);

CString m_strContent;
bool m_bActive;
};

int CMyNetSupport::OnLineReceived(char* szLine)
{
CString strLine(szLine);

if (strLine.Find("<!--LISTING ANFANG-->") >= 0)
m_bActive = true;
if (strLine.Find("<!--LISTING ENDE-->") >= 0)
m_bActive = false;

if (m_bActive)
m_strContent += strLine;

return 1;
}

void CTvselectDlg::DoGetTVProgram()
{
CMyNetSupport net;

FILE* fp = fopen("e:/projects/internet/my_home/kaiserreich/tvprog.htm", "w+t");
if (fp)
{
//kopf
fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
"<html><head><title>TV Programm</title></head><body>\n\n", fp);
fputs("<h1>TV Programm</h1>", fp);

//ard
fputs("<h2>ARD</h2>", fp);

net.ReadHTTPsingle("http://www.tvtoday.de/tv/programm/programm.php?ztag=0&sparte=alle&uhrzeit=Ax19&sender=ARD");
net.m_strContent.Replace("/tv/programm/bilder/senderlogos/"
, "/kaiserreich/images/k_images/");
net.m_strContent.Replace("weitere Sendungen "
, "");
fputs(net.m_strContent, fp);
net.m_strContent = "";

//zdf
fputs("<h2>ZDF</h2>", fp);

net.ReadHTTPsingle("http://www.tvtoday.de/tv/programm/programm.php?ztag=0&sparte=alle&uhrzeit=Ax19&sender=ZDF");
net.m_strContent.Replace("/tv/programm/bilder/senderlogos/"
, "/kaiserreich/images/k_images/");
net.m_strContent.Replace("weitere Sendungen "
, "");
fputs(net.m_strContent, fp);
net.m_strContent = "";

//sw3
fputs("<h2>SW3</h2>", fp);

net.ReadHTTPsingle("http://www.tvtoday.de/tv/programm/programm.php?ztag=0&sparte=alle&uhrzeit=Ax19&sender=SW+III");
net.m_strContent.Replace("/tv/programm/bilder/senderlogos/"
, "/kaiserreich/images/k_images/");
net.m_strContent.Replace("weitere Sendungen "
, "");
fputs(net.m_strContent, fp);
net.m_strContent = "";

//das wars
fclose(fp);
}
}