Quantcast
Channel: HAKER - Forum Komputerowe
Viewing all articles
Browse latest Browse all 4549

Pobieranie tekstu z www TCP/IP

$
0
0
Witam, chciałbym ze strony www pobrać tekst, ale nie wiem czemu program nie wyświetla nic, proszę o pomoc!
Pracuję w Qt creator
Kod:

void MainWindow::on_pushButton_wyslij_clicked()
{
    // QHostInfo info = QHostInfo::fromName(ui->lineEdit_nazwadomeny->text());
    QHostInfo info = QHostInfo::fromName( "www.wp.pl" );
    QTcpSocket socket;
    socket.connectToHost( info.addresses().first(), 80 );
 
    if( socket.waitForConnected( 3000 ) )
    {
        QString request = QString( "GET / HTTP/1.1\nHost: www.wp.pl \n\n" );
     
        socket.write( request.toLatin1() );
        QByteArray arr;
     
        if( socket.waitForBytesWritten() )
        {
            while( socket.waitForReadyRead( 500 ) )
            {
                arr.push_back( socket.readAll() );
            }
            QTextDocument * doc = new QTextDocument( this );
            doc->setHtml( QString::fromUtf8( arr ) ); //dodaje kontent html dokumentu
            ui->textBrowser_wyswietlanie->setDocument( doc );
        }
        socket.disconnectFromHost();
     
    }
 
}


Viewing all articles
Browse latest Browse all 4549

Trending Articles


TRX Antek AVT - 2310 ver 2,0


Автовишка HAULOTTE HA 16 SPX


POTANIACZ


Zrób Sam - rocznik 1985 [PDF] [PL]


Maxgear opinie


BMW E61 2.5d błąd 43E2 - klapa gasząca a DPF


Eveline ➤ Matowe pomadki Velvet Matt Lipstick 500, 506, 5007


Auta / Cars (2006) PLDUB.BRRip.480p.XviD.AC3-LTN / DUBBING PL


Peugeot 508 problem z elektroniką


AŚ Jelenia Góra