Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Inet.au3>
- $link = 'http://www.youtube.com/watch?v=IG-pvi3F53E'
- $id = 'IG-pvi3F53E' ;Tự lấy trên link xuống vì lười code
- $get = 'http://www.youtube.com/get_video_info?video_id=' & $id
- $rev = _INetGetSource($get) ;Lấy dữ liệu trả về
- $tit = ''
- For $i = 1 To StringLen($rev)
- If StringMid($rev,$i,6)= 'title=' Then ;Tìm chuỗi 'title='
- For $j = $i+6 To StringLen($rev)
- If StringMid($rev,$j,1) = '&' Then ;Điều kiện dừng
- ExitLoop
- Else
- $tit = $tit & StringMid($rev,$j,1) ;Nếu không dừng thì thực hiện việc lấy chuỗi
- EndIf
- Next
- EndIf
- Next
- MsgBox(0,'',_UnicodeURLDecode($tit)) ;Giải mã URL và cho vào msgbox
- ;Phần này là UDF Mã hóa, giải mã URL
- ;===============================================================================
- ; _UnicodeURLEncode()
- ; Description: : Encodes an unicode string to be URL-friendly
- ; Parameter(s): : $UnicodeURL - The Unicode String to Encode
- ; Return Value(s): : The URL encoded string
- ; Author(s): : Dhilip89
- ; Note(s): : -
- ;
- ;===============================================================================
- Func _UnicodeURLEncode($UnicodeURL)
- $UnicodeBinary = StringToBinary ($UnicodeURL, 4)
- $UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1)
- $UnicodeBinaryLength = StringLen($UnicodeBinary2)
- Local $EncodedString
- For $i = 1 To $UnicodeBinaryLength Step 2
- $UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2)
- If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString ('0x' & $UnicodeBinaryChar, 4)) Then
- $EncodedString &= BinaryToString ('0x' & $UnicodeBinaryChar)
- Else
- $EncodedString &= '%' & $UnicodeBinaryChar
- EndIf
- Next
- Return $EncodedString
- EndFunc ;==>_UnicodeURLEncode
- ;===============================================================================
- ; _UnicodeURLDecode()
- ; Description: : Tranlates a URL-friendly string to a normal string
- ; Parameter(s): : $toDecode - The URL-friendly string to decode
- ; Return Value(s): : The URL decoded string
- ; Author(s): : nfwu, Dhilip89
- ; Note(s): : Modified from _URLDecode() that's only support non-unicode.
- ;
- ;===============================================================================
- Func _UnicodeURLDecode($toDecode)
- Local $strChar = "", $iOne, $iTwo
- Local $aryHex = StringSplit($toDecode, "")
- For $i = 1 To $aryHex[0]
- If $aryHex[$i] = "%" Then
- $i = $i + 1
- $iOne = $aryHex[$i]
- $i = $i + 1
- $iTwo = $aryHex[$i]
- $strChar = $strChar & Chr(Dec($iOne & $iTwo))
- Else
- $strChar = $strChar & $aryHex[$i]
- EndIf
- Next
- $Process = StringToBinary (StringReplace($strChar, "+", " "))
- $DecodedString = BinaryToString ($Process, 4)
- Return $DecodedString
- EndFunc ;==>_UnicodeURLDecode
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement