Results 1 to 10 of 10

Thread: Hot do I get HTML source from a web page?

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Hot do I get HTML source from a web page?

    I've been trying using this code, but failed:

    QHttp *http;
    http->setHost("subdivx.com");
    http->get(QUrl::toPercentEncoding("/index.html"));

    QByteArray text = http->readAll();
    ui->textBrowser->setText(text);

    As you can see, I just want to display the html code of some web page in a textBrowser.

    What am I doing wrong here? Please, I need your help!

    Thanks in advance!

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Hot do I get HTML source from a web page?

    Is this all your code or did you 'shorten' it a bit for our convenience? If this is what you really do, you might not understand the concept of asynchronicity. You cannot just sent a http request and at once try to read from QHttp. Connect a slot and wait for the signal, which tells you that your requested data actually arrived.

  3. #3
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hot do I get HTML source from a web page?

    Ok. Thanks a lot. Finally, I made it work!! Thanks for the tip! It was very useful... really!

  4. #4
    Join Date
    Dec 2009
    Posts
    9
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hot do I get HTML source from a web page?

    Hi.
    Can you put this code here? I'm started to learning programming in Qt, and I want write tool to finding something in source of page.

    Thanks in advance.

    PS. Sorry for my English

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Hot do I get HTML source from a web page?

    Please do not use QHttp. Start with QNetworkAccessManager and the HTTP Example. For something more complex: Download Manager Example.

  6. #6
    Join Date
    Dec 2009
    Posts
    9
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hot do I get HTML source from a web page?

    Thanks a lot, but I don't need this. I want to make program which download only source, then finds lines which I'm interested in and makes list of these lines.
    Please show explain how I can do this.

    Thanks

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Hot do I get HTML source from a web page?

    Thanks a lot, but I don't need this. I want to make program which download only source
    Hmmm, that would be the bit I gave you
    then finds lines which I'm interested in and makes list of these lines.
    Please show explain how I can do this.
    You do it by learning some basic programming, then reading the manual and trying to do it for yourself. Here are some places to start.
    QFile or QBuffer, QRegExp, QString, QStringList.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hot do I get HTML source from a web page?

    Quote Originally Posted by Roszko View Post
    I'm started to learning programming in Qt, and I want write tool to finding something in source of page.
    Quote Originally Posted by Roszko View Post
    Thanks a lot, but I don't need this.
    If you expected to be given code that does exactly what you want then what would have that taught you? Certainly not programming... copy&pasting, maybe...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Dec 2009
    Posts
    9
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hot do I get HTML source from a web page?

    @up.

    I don't want ready code of course, but some example codes using these libraries.

    Now when I know that what libs i have to use in code, I will try do it by myself

    Again sorry for my English :P

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hot do I get HTML source from a web page?

    You have been given an example and yet you said it was doing something else than what you wanted.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Html page Display in QWebView
    By Tavit in forum Qt Programming
    Replies: 4
    Last Post: 10th July 2010, 16:39
  2. how to get source code of a web page
    By mmm286 in forum Newbie
    Replies: 7
    Last Post: 17th March 2010, 19:47
  3. Download Page Source of Website
    By AjRomano in forum Newbie
    Replies: 3
    Last Post: 11th March 2010, 07:22
  4. Read the source page of url? SOLVED
    By triperzonak in forum Qt Programming
    Replies: 0
    Last Post: 19th September 2008, 10:44
  5. Widget to display an HTML page ?
    By probine in forum Qt Tools
    Replies: 3
    Last Post: 11th October 2006, 19:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.