Deepl Cookie

west555

Senior Member
Joined
Dec 4, 2011
Messages
1,004
Reaction score
455
Am trying to translate text on deepl.com via HTTP requests and I fail to set cookies and I need to be logged in, in order to bypass the character limit ( I pay for pro package on deepl )
i have made the cookie and set its value but i don't know how to add it to the request to be used.
All the examples i find on the internet are not helpful in my case

here is my code so if anyone can help I would appreciate it
Try

Dim oCookies As CookieContainer = New CookieContainer()
Dim cookie As New HttpCookie("UserName")
cookie.Value = " Value of my cookie from live headers addon on firefox"
Dim PageSource As String = String.Empty
Dim Request As HttpWebRequest = HttpWebRequest.Create("https://api.deepl.com/jsonrpc?method=LMT_handle_jobs")
Request.Host = "api.deepl.com"
Request.Timeout = System.Threading.Timeout.Infinite
Request.KeepAlive = True
Request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0"
Request.ProtocolVersion = HttpVersion.Version11
Request.Method = WebRequestMethods.Http.Post
Request.CookieContainer = oCookies
Request.ContentType = "application/json;charset=utf-8"
Request.Referer = "https://www.deepl.com/"
Request.Accept = "application/json, text/plain, */*"
Dim post As String = "My post data"
Request.ContentLength = post.Length
Dim writer As New StreamWriter(Request.GetRequestStream)
writer.Write(post)
writer.Close()
Dim Response As HttpWebResponse = Request.GetResponse()
Dim reader As New StreamReader(Response.GetResponseStream())
PageSource = reader.ReadToEnd()
Response.Close()

If PageSource.Contains("gpt_generations") Then
Dim Paraphrased As String = PageSource

Else


End If


Catch ex As Exception
If ex.ToString.Contains("to many requests") Then
MsgBox("TO MANY REQUESTS EXITING ON : " & fName)
Exit Sub
Else
End If


Finally
 
Check the documentation about deepl API - https://www.deepl.com/ru/docs-api/accessing-the-api/api-versions/
You need to get authentication key from account settings. You dont need a cookies and other headers from web browser.
 
Then why do you call the api?
I got that url from header sniffing even on normal requests :/
and that was before i calculate the price that i will have to pay to translate all i need via api.
ignore the url. Can you help me to get logged in via cookie to normal account url ?
 
So you want to fck the system?) Try "postman" to making requests and debug this, after you can automatic translate into any code.
Hmm never tried postman, but looks interesting. Ill check it out.
 
You forget the add a cookie to the cookie container in your code after assigned data to the cookie object

oCookies.Add(cookie)

See if that work


Love the VB.NET :)
 
You forget the add a cookie to the cookie container in your code after assigned data to the cookie object

oCookies.Add(cookie)

See if that work


Love the VB.NET :)
Ill try that too.
 
Back
Top