كود :
Try
Dim email As String = Uri.EscapeDataString(Me.TextBox1.Text)
Dim pass As String = Uri.EscapeDataString(Me.TextBox2.Text)
Me.chromeDriver = ChromeFactory.NewInstanceAccount
Me.chromeDriver.Navigate().GoToUrl("https://compte-canal.canal-plus.com/oauth2/authentication?displayTvByCanal=true&from=idpoauth2&idpName=myCANAL&omnitureChannel=mycanal&pass_target=https%3A%2F%2Fpass.canal-plus.com%2FIdPOAuth2%2Fauth%2Fmycanal%3Fclient_id%3D2E4A08AA4ACEF15A%26portailId%3DvbdTj7eb6aM.%26redirect_uri%3Dhttps%253A%252F%252Fwww.canalplus.com%252F%26response_type%3Dcode%26scope%3Dpass_profile%2520email%26state%3Dorigref%253Dhttps%253A%252F%252Fwww.canalplus.com%252F&portailId=0&socialLinksDisabled=true&sourceURL=https%3A%2F%2Fpass.canal-plus.com%2FIdPOAuth2%2Fauth%2Fmycanal%3Fclient_id%3D2E4A08AA4ACEF15A%26portailId%3DvbdTj7eb6aM.%26redirect_uri%3Dhttps%253A%252F%252Fwww.canalplus.com%252F%26response_type%3Dcode%26scope%3Dpass_profile%2520email%26state%3Dorigref%253Dhttps%253A%252F%252Fwww.canalplus.com%252F&ssoconf=auth_oauth2")
Thread.Sleep(4000)
chromeDriver.FindElement(By.Id("sso-email")).SendKeys(email)
chromeDriver.FindElement(By.Id("sso-pass")).SendKeys(pass + Keys.Enter)
Thread.Sleep(4000)
chromeDriver.FindElement(By.XPath("//body/div[@id='application']/div/section[@class='application___387lb application--cover___25B7i']/header[@class='header___1qRCL']/div[@class='header__container___2CcIt header__container--transparent___dM5fo header__container--initial___1qVkP header__container--withNav___2raIC']/div[@class='bottomBar___37bGe']/div[@class='bottomBar__wrapper___1SjzV']/nav[@class='navigation___1TcRy navigation--transparent___2T1Lc navigation--transparent___3rfCN navigation--asideComponent___hMnOO']/div[@class='navigation__wrapper___2XoaC navigation__wrapper___26m51']/ul[@class='navigation__items___2_XoB navigation__items___uOvIY']/li[@class='navigationItem___1YN_p navigationItem___2upoq navigationItem___2RXmo']/a/span/*[1]")).Click()
Thread.Sleep(1000)
Dim javaScriptExecutor As IJavaScriptExecutor = TryCast(Me.chromeDriver, IJavaScriptExecutor)
Dim text As String = CStr(javaScriptExecutor.ExecuteScript("return document.cookie", New Object(-1) {}))
Dim baseUrl As String = ""
Dim restClient As RestClient = New RestClient(baseUrl)
Dim request As RestRequest = New RestRequest(Method.POST)
Dim restResponse As IRestResponse = restClient.Execute(request)
Dim cancellationTokenSource As CancellationTokenSource = New CancellationTokenSource()
Dim restResponse2 As IRestResponse = restClient.Execute(request)
Dim content As String = restResponse2.Content
Dim flag As Boolean = content.Contains("You don't have permission to access")
If flag Then
Else
Dim num As Integer = content.IndexOf("s_token")
num = content.IndexOf("'", num + 1)
Dim num2 As Integer = content.IndexOf("'", num + 1)
Dim text2 As String = content.Substring(num + 1, num2 - num - 1)
Dim flag2 As Boolean = Not content.Contains("identifier")
If flag2 Then
Me.TextBox3.Text = text2
End If
Dim flag3 As Boolean = Me.chromeDriver IsNot Nothing
If flag3 Then
Me.chromeDriver.Quit()
End If
End If
Catch var_17_22B As Exception
Dim flag4 As Boolean = Me.chromeDriver IsNot Nothing
If flag4 Then
Me.chromeDriver.Quit()
End If
End Try