Thanks for your answer.
I am NOT using the PB functions to rd the HTML code because for some reason im not getting HTML but a crazy javascript response. Then i am using this funtions to get the page description of any videoand i am pasring the title, views, suscribers, tags, description... but in the description shows many emojis sometimes:
Code: Select all
Procedure.S HTTPRequestURL(url.S, ReturnType = 1, PostData.S = "", Cookie.S = "", User_agent.S = "", Referer.S = "", File_to_download.S = "", Proxy.S = "", Timeout.L = 30000, Redirect.b = #True)
;{ Format URL
If FindString(url, "https://", 1, #PB_String_NoCase)
Is_secure.b = #True
EndIf
url = RemoveString(url, "https://", #PB_String_NoCase)
url = RemoveString(url, "http://", #PB_String_NoCase)
Host.S = StringField(url, 1, "/")
page.S = RemoveString(url, Host, #PB_String_NoCase)
page.S = RTrim(page, "/")
;}
;{ Add headers
If Not Proxy = "" : Access_type.i = 3 : Else : Access_type.i = 1 : EndIf
If User_agent = "" : User_agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" : EndIf
Open_handle = InternetOpen_(User_agent, Access_type, Proxy, "", 0)
InternetSetOption_(Open_handle, 2, @Timeout, 4)
InternetSetOption_(Open_handle, 5, @Timeout, 4) ; #INTERNET_OPTION_SEND_TIMEOUT
InternetSetOption_(Open_handle, 6, @Timeout, 4) ; #INTERNET_OPTION_RECEIVE_TIMEOUT
InternetSetOption_(Open_handle, 7, @Timeout, 4) ; #INTERNET_OPTION_DATA_SEND_TIMEOUT
InternetSetOption_(Open_handle, 8, @Timeout, 4) ; #INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
If Is_secure : Port.i = 443 : Flag.L = $00800000|$00001000|$00002000|$00080000|$00000100|$04000000
Else : Port.i = 80 : Flag.L = $00080000|$00000100|$04000000 : EndIf
If Not Redirect : Flag|$00200000 : EndIf
If Not PostData = "" : Verb.S = "POST" : Else : Verb.S = "GET" : EndIf
If page = "" : page = "/" : EndIf
Connect_handle = InternetConnect_(Open_handle, Host, Port, "", "", 3, 0, 0)
Request_handle = HttpOpenRequest_(Connect_handle, Verb, page, "", Referer, 0, Flag, 0)
If Verb = "POST"
Headers.S = "Content-Type: application/x-www-form-urlencoded" + Chr(13) + Chr(10)
HttpAddRequestHeaders_(Request_handle, Headers, Len(Headers), $80000000|$20000000)
EndIf
If Not Cookie = ""
Headers.S = "Cookie: " + Cookie + Chr(13) + Chr(10)
HttpAddRequestHeaders_(Request_handle, Headers, Len(Headers), $80000000|$20000000)
EndIf
;}
;{ Send request
If #PB_Compiler_Unicode
*PostDataAnsi = AllocateMemory(StringByteLength(PostData, #PB_Ascii) + 1)
PokeS(*PostDataAnsi, PostData, -1, #PB_Ascii)
Send_handle = HttpSendRequest_(Request_handle, "", 0, *PostDataAnsi, StringByteLength(PostData, #PB_Ascii))
FreeMemory(*PostDataAnsi)
Else
Send_handle = HttpSendRequest_(Request_handle, "", 0, PostData, Len(PostData))
EndIf
;}
;{ Receive response
If ReturnType = 1 ; Return server response content
buffer.S = Space(1024)
Repeat
InternetReadFile_(Request_handle, @buffer, 1024, @Bytes_read.L)
Result1.S + Left(PeekS(@buffer,-1,#PB_Ascii), Bytes_read)
buffer = Space(1024)
Until Bytes_read = 0
ElseIf ReturnType = 2; Return Cookie(s)
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
ElseIf ReturnType = 3; Return both
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
Result1 + #CRLF$
buffer.S = Space(1024)
Repeat
InternetReadFile_(Request_handle, @buffer, 1024, @Bytes_read.L)
Result1.S + Left(PeekS(@buffer,-1,#PB_Ascii), Bytes_read)
buffer = Space(1024)
Until Bytes_read = 0
ElseIf ReturnType = 4; Download file
If File_to_download <> ""
Filehandle = CreateFile(#PB_Any, File_to_download)
fBytes.L = 0
Loop.b = 1
fBuffer = AllocateMemory(4096)
Repeat
InternetReadFile_(Request_handle, fBuffer, 4096, @Bytes_read.L)
If Bytes_read = 0
Loop = 0
Else
fBytes = fBytes + Bytes_read
WriteData(Filehandle, fBuffer, Bytes_read)
EndIf
Until Loop = 0
CloseFile(Filehandle)
Result1 = Str(FileSize(File_to_download))
FreeMemory(fBuffer)
Else
Result1 = ""
EndIf
ElseIf ReturnType = 5 ; return redirected URl + cookies
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
buffer.S = Space(#MAX_PATH)
Headernum = 0
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 33, @buffer, @length, @Headernum)
Result1 = buffer + #CRLF$ + Result1
EndIf
EndIf
;}
;{ Close handle
InternetCloseHandle_(Open_handle)
InternetCloseHandle_(Connect_handle)
InternetCloseHandle_(Request_handle)
InternetCloseHandle_(Send_handle)
Delay(70)
;}
ProcedureReturn Result1
EndProcedure
"<br /><br />✅ Todos los recursos mencionados en el video los puedes encontrar en el comentario fijado que lo encontraras abajo 👇ðŸ»ðŸ‘‡ðŸ»ðŸ‘‡ðŸ»"