mIRC Home    About    Download    Register    News    Help

Print Thread
* Invalid parameters: $bfind #269564 31/10/21 06:05 AM
Joined: Aug 2015
Posts: 63
_entropy Offline OP
Babel fish
OP Offline
Babel fish
Joined: Aug 2015
Posts: 63
You should get this: * /sockwrite: 'PRIVMSG' no such socket (line 382," because %_sock isnt defined
Instead: * Invalid parameters: $bfind
; Syntax: /WebsiteDataTester https://mirc.com - By Talon 2021
alias WebsiteDataTester { noop $urlget($1-,gb,& $+ $ticks,ScrapeWebsiteData) }
alias ScrapeWebsiteData { 
  var %b = $urlget($1).target
  if ($bfind(%b,1,/<title>(.*)<\/title>/i,Title).regex) { var %title = $regml(Title,1) }
  if ($bfind(%b,1,/<meta name="description".*content="([^"]+)"(?:[^>]+)?>/i,Desc).regex) { var %desc = $regml(Desc,1) }
  sockwrite -n %_sock PRIVMSG %_chan :[Title] $chr(9679) %title $iif(%desc,$chr(9679) %desc)

mIRC Scripts IRC Network: irc://irc.mircscripts.net/chat
Re: * Invalid parameters: $bfind [Re: _entropy] #269567 02/11/21 06:45 PM
Joined: Dec 2002
Posts: 5,134
Khaled Offline
Hoopy frood
Hoopy frood
Joined: Dec 2002
Posts: 5,134
Thanks for your bug report. When I test your script, I see a /sockwrite error.

Do you mean that you are seeing a /sockwrite error as well? And that you think you should see a $bfind() error?

If that's the case, why do you think you should see a $bfind() error? Did you add debug /echos to track what is happening?

Can you create a simple, one line script using $bfind() that reproduces your issue?

Re: * Invalid parameters: $bfind [Re: _entropy] #269568 03/11/21 03:16 AM
Joined: Dec 2002
Posts: 235
Talon Offline
Fjord artisan
Fjord artisan
Joined: Dec 2002
Posts: 235
this was meant to be a simplistic example showing one potential solution to attempt to parse out information from a website, specifically left out any form of error checking as to not get too convoluted and the method get lost behind all the extra bits... There is ZERO error checking in this example... You should test the $urlget(ID).state for "ok" or "fail" (fail will mean something went wrong so the binvar doesn't exist)

You should also look at the beginning of $urlget(Id).reply (which is an unusual name scheme for the return headers...) for the specific return code also before attempting to process any further, which can give you insight on if the binvar will contain anything, or to why your request failed.

Other reasons could be usage, like using other options like "hpuad"
h=head (request headers only, no body)

u=put (You're pushing a resource, and awaiting a conformation header upon completion)

a=patch (you're pushing a partial modification to a resource, and awaiting a conformation header upon completion)

d=delete (you're requesting a resource be removed, and awaiting a conformation header upon completion)

p=post (your body is form data, typically used with a header of Content-type: multipart/form-data accompanied by a Content-Length: of how many bytes are within your post body. multipart/form-data uses a boundary to isolate form fields typically used for items such as file-uploads. You don't have to use multipart/form-data, it could also represent form-data similar to a query-string from a GET request, the extra bits after the "?")

Typically a successful POST results in a return body, but does not have to...

I believe any HTTP response NOT in the 200's range will result in the binvar not being filled, 400+ range will result in a $urlget(Id).state of "fail".

In your case, the response from the server was a 403 forbidden, resulting in $urlget(Id).state being a "fail" and nothing being filled into the binvar.

The most common responses are as follows:
101=Switching Protocols
203=Non-Authoritative Information
204=No Content
205=Reset Content
206=Partial Content
300=Multiple Choices
301=Moved Permanently
303=See Other
304=Not Modified
305=Use Proxy
307=Temporary Redirect
400=Bad Request
402=Payment Required
404=Not Found
405=Method Not Allowed
406=Not Acceptable
407=Proxy Authentication Required
408=Request Time-out
411=Length Required
412=Precondition Failed
413=Request Entity Too Large
414=Request-URI Too Large
415=Unsupported Media Type
416=Requested range not satisfiable
417=Expectation Failed
426=Upgrade Required
431=Request Header Fields Too Large
500=Internal Server Error
501=Not Implemented
502=Bad Gateway
503=Service Unavailable
504=Gateway Time-out
505=HTTP Version not supported