如何转义并替换正确的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)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...