Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias erpk {
- if ($sock(erpk)) { sockclose erpk }
- sockopen erpk erpk-api.com 80
- }
- on *:sockopen:erpk:{
- sockwrite -n $sockname GET /citizen/profile/2109804.json?key=fkqquQ2Y8v HTTP/1.1
- sockwrite -n $sockname Host: erpk-api.com
- sockwrite -n $sockname user-agent: Mozilla/??
- sockwrite -n $sockname Connection: Keep-Alive
- sockwrite -n $sockname $crlf
- }
- on *:sockread:erpk:{
- if ($sockerr > 0) {
- echo -a SOCKET ERROR: $sockerr
- halt
- }
- sockread &t
- ;at this point all of the info read from the page is held in the binary variable &t and you can view it with echo -a $bvar(&t,1-).text
- var %sockreader $bvar(&t,$calc($bfind(&t,1,13 10 13 10) + 4) $+ -).text
- ;this line above looks complicated is what it does is _finds_ in the bvar the location of 13,10,13,10 which is the same as two $crlf in a row
- ;and two $crlf in a row is hitting enter twice (or means the actual page starts past the headers like HTTP OK and whatever
- ;so now all we have to do is parse out the part that you want, in this case the ID
- var %ex $gettok(%sockreader,2,44)
- ;this is because NAME is in the second COMMA (which has an ascii value of 44)
- var %ex $gettok(%ex,2,58)
- ;this is because the actual name is after the COLON (which has an ascii value of 58)
- msg #gervasio $noqt(%ex)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement