Solved How can I get things from website
-
@jsulm
That mean i have to add QFile function into replyFinished() SLOT right?ReadAll function actually it call twice by itself and i don't know why it will happened.
I'm sure that i just call one time for the ReadAll function.
This is my code here.But when I add it into replyFinished() slot, it cannot connect to server.
The connect_url will return 0 for the second time to me like this.
What can i do? -
@victor-wang YES
"ReadAll function actually it call twice by itself" - how can a function call itself?
You do it twice, please check your own code again. First time: line 1999, second time line 2013. -
@jsulm
Thank you for telling me!
But now i still get nothing.
I had check several time that i can wget the Url on the console.
And i'm sure it is the right subnet and Url.
And i checked the check.txt file can be write nor read.
Why it still print NULL out? -
@victor-wang show your code
-
-
@victor-wang You cannot write in /home! (line 2019)
It should be /home/YOUR_USER_NAME/check.txt -
@victor-wang What do you get if you use wget with that URL? Any data?
-
-
@victor-wang You should print out reply->error()
If everything was fine then it should print out 0 (QNetworkReply::NoError) -
@jsulm
It shows no error.
That means everything was fine.
But why still have nothing?
Is there any possible because i receive a file? -
@victor-wang Is that out variable a QByteArray?
Also, what exactly does qDebug()<<out print out? -
-
@victor-wang can you do qDebug()<<out.size();?
-
-
@victor-wang said in How can I get things from website:
If it is how can i judge the signal and where do i have to add the function in?
You make a signal-slot connection, using
QObject::connect()
. When the signal is emitted, the connected slot will run automatically.This is a core feature of Qt. I recommend you spend some time to do tutorials to understand how to use signals and slots.
For the first of debugging and testing.
I will get this on my browser. hereOK, good. That means the server will give you text data.
For the second one, i'm not quite sure what does that mean.
Your code has
QUrl("http://192.168.100/59/...")
. Change this toQUrl("http://lists.qt-project.org/mailman/listinfo")
for testing.For third one, what does"QNetworkRequest constructly correctly"mean?
I thought i am using the library that Qt have already constructed.When you call
QNetworkRequest(QUrl(...));
you are constructing a QNetworkRequest.Let's check that your QNetworkReply is what you expect. Put this in your
replyFinished()
slot:qDebug() << reply->isFinished(); qDebug() << reply->error(); qDebug() << reply->request(); qDebug() << reply->url(); qDebug() << reply->rawHeaderPair();
For forth one, I'm sure i am on the same subnet because i can send this commend to my console
wget http://192.168.100.59/PLMS/TestCheck.asp?LSN=201503003009&EmpId=we9999&CPID=OS&CPKey=95Z0000000AF
And i will get the file and the content will show "updated ok".
OK, good.
-
for your Xming copy/paste problem to windows, take a look to this topic:
https://superuser.com/questions/440128/xming-clipboard-only-works-one-way
That should enable you to poste your code as text for us and not as pictures.
-
-
-
@victor-wang said in How can I get things from website:
@JKSH
I have try to get from the Url which you gave me for test.
And i will get this information here.So is that mean the code is not wrong?
Yes, your code is working correctly. Go to http://lists.qt-project.org/mailman/listinfo using your browser and view that web page's source (Ctrl+U in Google Chrome) -- it's the same as your last screenshot.
Your code is not wrong. Your device (192.168.100.59) probably returns data in a different way. Fix the errors below to investigate.
@victor-wang said in How can I get things from website:
@JKSH
I add the qDebug in the replyFiniched() slot but i got some errors.
HereOops, sorry... QNetworkRequest can't be printed through qDebug(). Just delete this line:
qDebug() << reply->request();
The other one should be
rawHeaderPairs()
, not rawHeaderPair() -