0

I want to scrape google translate, however, the translation result is generated in javascript rather than HTML, and Jsoup library doesn't support extracting javascript code.

This is the code that I want to extract from the website, which changes dynamically depending on the query:

<div class="xUPQqb" jsname="gm7qse" lang="en">hello</div>

Any help?

Roony
  • 132
  • 15
  • 2
    If it uses Javascript you have to load the page into a webview. To control the webview you can inject JavaScript code https://stackoverflow.com/q/7282789/150978 But be aware that Google can and will change the identifier or the whole page at any time. So even if you succeed you will have to update your code every month or may be even more often. – Robert May 11 '23 at 07:21
  • @Robert I could add a javascript interface, but I don't have any idea of how to use it to extract a specific javascript code, could you show me an example of how that would be done? – Roony May 11 '23 at 07:52
  • Please first search here on Stackoverflow how to read/extract DOM elements via Javascript, you should be able to find a lot of answers. – Robert May 11 '23 at 08:39
  • @Robert I tried it but I don't get any result, I've posted another question: https://stackoverflow.com/questions/76227075/extracting-dom-fails-in-android – Roony May 11 '23 at 12:38

0 Answers0