After a lot of time i finally got a working script, should then make a gui and a menu to search for books but no time by now. I hope someone need the script or do something similar so here is what i did:
Code:
;SearchAndDownloadBook(4235) ;Ex
Global Const $HTTP_STATUS_OK = 200
Func HttpPost($sURL, $sData = "")
Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("POST", $sURL, False)
If (@error) Then Return SetError(1, 0, 0)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($sData)
If (@error) Then Return SetError(2, 0, 0)
; not working don't know doesn't matter If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0)
Return SetError(0, 0, $oHTTP.ResponseText)
EndFunc
Func SearchAndDownloadBook($bookId) ;search book by id
$Link = HttpPost("http://bajaebooks.org/wp-admin/admin-ajax.php","action=PDOBookLink&id="&$bookId)
DownloadBook($Link)
EndFunc
Func DownloadBook($link)
$sp = StringSplit($link,"/",2)
$id = $sp[UBound($sp)-1] ;get book id
$var = _
"GET /f/"&$id& " HTTP/1.1" & @CRLF & _
"Host: bajafiles.com" & @CRLF & _
"Connection: keep-alive" & @CRLF & _
"Accept-Encoding: gzip, deflate, sdch" & @CRLF & _
"Accept-Language: es-419,es;q=0.8" & @CRLF & @CRLF
;first request to the server should get the cookie here
TCPStartup()
$con = TCPConnect("195.154.242.91",80)
TCPSend($con,$var) ;send request
While 1
$recv = TCPRecv($con,2048)
If StringLen($recv) <> 0 Then ExitLoop
WEnd
$recv = BinaryToString($recv)
$cookie = StringRegExp($recv,"(?i)Set-Cookie:(.*?);",2);get cookie from string
$myCookie = $cookie[1]
$var = _
"GET /get/"&$id&" HTTP/1.1" & @CRLF & _
"Host: bajafiles.com" & @CRLF & _
"Cookie: "&$myCookie & @CRLF & _
"Connection: keep-alive" & @CRLF & _
"Referer: http://bajafiles.com/f/"&$id & @CRLF & _
"Accept-Encoding: gzip, deflate, sdch" & @CRLF & _
"Accept-Language: es-419,es;q=0.8" & @CRLF & @CRLF
;second request now with the cookie
TCPSend($con,$var)
While 1
$recv = TCPRecv($con,2048)
If StringLen($recv) <> 0 Then ExitLoop
WEnd
$recv = BinaryToString($recv)
$url = StringRegExp($recv,"(?i)Location:(.*?)\r",1);Get url
$lin = StringStripCR($url[0]) ;remove cr
$nameA = StringSplit($lin,"/",2)
$name = $nameA[UBound($nameA)-1];get file name from url
InetGet($lin,$name) ;download file
TCPCloseSocket($con)
EndFunc






