Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

3 876 Posts in 868 Topics- by 723 Members - Latest Member: tablarock

22 May 2012, 17:17
Select Language English | Russian ru | German
Main PageIRC Client KVIrc forumKVIrc discussionKVIrc scripting[HTTP Class] Problem getting content.
Pages: [1]
Print
Author Topic: [HTTP Class] Problem getting content.  (Read 1683 times)
0 Members and 2 Guests are viewing this topic.
Windlaze
Новичок
*

Репутация: 0
Posts: 1


View Profile Email
« on: 9 January 2011, 09:32 »

Hello everyone.

I'm trying to get content (text) from a page and I was testing the HTTP class but I can't make it work.

The script looks like this:

Code:
...

%http = $new(http, 0,http)

%http->$get("http:\/\/www. someweb .com")

%http->$readAll()

...

So, i was wondering, the HTTP class is the correct for that? Am i doing it right or I must user Socket class instead?

I've searched for a tutorial of HTTP Class but i didn't find it and it seems that i can't do it work for myself (;_;).



Logged
alexzulu
Постоялец
***

Репутация: 29
Posts: 181



View Profile Email
« Reply #1 on: 20 February 2011, 23:01 »

Code:
%http = $new(http)
%http->$setHost("www.kvirc.ru")
%http->$get("/addons/index.php","$file.homedir/index.php")
Logged

сеть freenode, каналы #kvirc и #kvirc-ru
ambossarm
Постоялец
***

Репутация: 11
Gender: Male
Posts: 113



View Profile
« Reply #2 on: 8 March 2011, 05:05 »

now that I had myself problems with the http class, I may help a bit

the ->$readAll() does not work YET, I tried it manually with a global var and some time between it and it worked. That is because the data is not ready if you trigger it without control.


The easiest way is to implement a class yourself and trigger your script in an overwritten doneEvent or readyReadEvent


Code:
class("myhttp","http")
{
function doneEvent()
{
%answer = @$readAll();
echo -w=@%windowid %answer;
}

function config()
{
@$setHost($0);
@$get($1);
#the next is the window ID to echo it into the right window
@%windowid = $2;
}
}

%http = $new(myhttp);
%http->$config("<HOSTNAME>","<URLPATH",$channel($target));
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic