微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何转义并替换正确的uri?

如何解决如何转义并替换正确的uri?

我想使用请求从HTML源中转出\/\/,以使该URL上的Uri.UnescapeDataString("\/\/")成为拇指,

https:\/\/scontent.fhel5-1.fna.fbcdn.net\/v\/t15.5256-10\/fr\/cp0\/e15\/q65\/48734886_2061090874011522_801576553975644160_n.jpg?_nc_cat=107&_nc_sid=08861d&_nc_ohc=4jeujL2uPDwAX_FBn97&_nc_ht=scontent.fhel5-1.fna&oh=672481858f1d7a2bd2655da89b57bacd&oe=5F63E18C

所以我的thumb将被解码并替换那些符号,以便可以在显示图片imgCover.ImageLocation = _thumbURL.ToString()的情况下将其解析为字符串

我的代码

   Private Sub getNFO()
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
    Dim apiURL As String = "https://m.facebook.com/watch/?v=" 
    Dim _videoID As String = txtURL.Text
   
    Try
        Dim the_request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(apiURL + _videoID)
        the_request.UserAgent = "Mozilla/5.0 (iPhone; cpu iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML,like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1"
        the_request.Timeout = 5000
        Dim the_response As System.Net.HttpWebResponse = the_request.GetResponse
        Dim stream_reader As System.IO.StreamReader = New System.IO.StreamReader(the_response.GetResponseStream())
        Dim yt_source As String = stream_reader.ReadToEnd

        If String.IsNullOrEmpty(yt_source) Then
            MessageBox.Show("Facebook ID Request Error")
        Else
            Dim r1 As Regex = New Regex("(?<=description"":"").*?([^[]+?)(?="")")
            Dim m1 = r1.Match(yt_source)
            _titleURL = m1.Value

            Dim r2 As Regex = New Regex("(?<=thumbnailUrl"":"").*?([^[]+?)(?="")")
            Dim m2 = r2.Match(yt_source)
            _thumbURL = m2.Value 

        End If

        lbl_Title.Text = _titleURL.ToString()         
        imgCover.ImageLocation = _thumbURL.ToString()

    Catch ex As Exception
         MessageBox.Show(ex.Message)
    End Try

End Sub

解决方法

最后由我自己制作:)

Dim decodedThumbURL = _thumbURL.Replace("\",String.Empty)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。