Я новичок в kotlin. у меня есть этот рабочий код на Python:
r = s.post(url, "Email=andr@gmail.com&Password=ofrot", headers={"content-type": "application/x-www-form-urlencoded",'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'})
soup = BeautifulSoup(r.text, 'html.parser')
я пытался сделать то же самое в jsoup, но он возвращает страницу входа (как будто я еще не вошел в систему)
val wiki = "https://account.reverso.net/login/context.reverso.net/it?utm_source=contextweb&utm_medium=usertopmenu&utm_campaign=login"
class MainActivity : AppCompatActivity() {
private val TAG = "MainActivity"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
class DownloadData : AsyncTask<String, Void, String>() {
private val TAG = "DownloadData"
override fun onPostExecute(result: String?) {
super.onPostExecute(result)
Log.d(TAG, "onPostExecute: parameter is $result")
}
override fun doInBackground(vararg url: String?): String {
Log.d(TAG, "doInBackground: starts ")
val visualizzo = Jsoup.connect(wiki).userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36").get() // <1>
// val dolce=rssFeed.cookie("JSESSIONID")
val rssFeed = Jsoup.connect(wiki).data("email", "andr@gmail.com")
.data("pass", "ofrot").data("content-type", "application/x-www-form-urlencoded").userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36").post() // <1>
return rssFeed.toString()
}
private fun downloadXML(urlPath: String?): String {
return URL(urlPath).readText()
}
}
val testo=DownloadData().execute()
println(testo.toString())
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////