I am trying to get the src URL for the captcha from this website using jsoup. The problem is when I use inspect in chrome, it shows me the URL of captcha but when I access it using jsoup in my android project, the return html doesn't contain any img field and src that contain the link of captcha image. It is kind of hidden in html but only show when I use the inspect thing in chrome. I want to get the url so that I can download the captcha and show it in my imageview. Here is the link to the website.
https://cms.bahria.edu.pk/Logins/Student/ForgotPassword.aspx
and here is the html and as you can see it's not showing the img tags.
Here is the code I have written so far
private class forgetpassword extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... voids) {
try {
Document document = Jsoup.connect("https://cms.bahria.edu.pk/Logins/Student/ForgotPassword.aspx").get();
Element img = document.select("div#AspireCaptcha").first();
if (img == null) {
throw new RuntimeException("Unable to locate image in ");
}
String imgSrc = img.absUrl("src");
bitmaps = BitmapFactory.decodeStream((InputStream) new URL(imgSrc).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
imageView.setImageBitmap(bitmaps);
}
}
It would really helpful if you guys could guide me to solve this problem. I am really stuck at this problem for days.