mIRC Home    About    Download    Register    News    Help

Print Thread
#39348 03/08/03 05:19 AM
Joined: Mar 2003
Posts: 49
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2003
Posts: 49
I want to build a News bot and when i want to get news from
news.walla.co.il i can, tell me please what the problam

i doing
/sockopen nana news.nana.co.il 80
and the code
on *:sockopen:walla: {
if ($sockerr == 0) {
echo -ta Connected to news server walla!
sockwrite -tn $sockname GET http://news.walla.co.il
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname $crlf
}
elseif ($sockerr != 0) {
echo -ta Can't connect to site Walla
.halt
}
}
on *:sockread:walla: {
sockread %walla
if (%walla != $null) {
echo %walla
}
}
and this wrote to me :
HTTP/1.1 400 Bad Request
Content-Type: text/html
Content-Length: 87
Connection: close

#39349 03/08/03 05:48 AM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Try using the exact example in the helpfile for On Sockread. You need to check for $sockerr first, and you also need to loop until nothing if left in $sockbr

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#39350 03/08/03 07:51 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
try this..

Code:
alias getNews {
  if ($sock(wallanews)) /sockclose wallanews
  /sockopen wallanews news.walla.co.il 80
}

on 1:SOCKOPEN:wallanews: {
  if ($sockerr) var %err = $input(Error connecting to http://news.walla.co.il/, ow, Error: Could Not Connect)
  else {
    /sockwrite -n $sockname GET / HTTP/1.0
    /sockwrite -n $sockname Host: news.walla.co.il
    /sockwrite -n $sockname $crlf
    /set -u10 %wallaHeader 1
  }
  if ($isFile(wallaNews.htm)) .remove wallaNews.htm
}

on 1:SOCKREAD:wallanews: {
  if (%wallaHeader) {
    /sockread -f %data
    if (%data == $null) /unset %wallaHeader
  }
  else {
    /sockread -f &data
    /bwrite wallaNews.htm -1 -1 &data
  }
  .timerwallanews 1 1 /readNews
}

alias readNews {
  ; do here whatever you wish with the file after you have downloaded it.
  ; it is now saved to "wallaNews.htm"
  /run wallaNews.htm
}


This will download the webpage for u, and open it. From there, take the alias "readNews" and do what you wish with the file "wallaNews.htm"


-KingTomato

Link Copied to Clipboard