I want to scrap the phonetic guide for a translation in Google Translator using Google Sheets.

For instance, if you enter the page:


…you will see a transliteration of 欢迎你 into Huānyíng nǐ (Welcome!). I want to extract only the transliteration. (Huānyíng nǐ). If I inspect the Web page code I see that this sentence is stored into:

<div class="tlid-transliteration-content transliteration-content full">Huānyíng nǐ</div>

…so I tried to extract this transliteration using IMPORTXML typing the following code:

=importxml("https://translate.google.com/#view=home&op=translate&sl=auto&tl=zh-CN&text=欢迎你";"//div[@class='tlid-transliteration-content transliteration-content full']")

But the result is #N/A. It's supposed to be that //div[@class='name-of-the-element']" would do the trick. Where is the error? How can I import this specific result?


Unfortunately, that won't be possible the way you trying because the field you attempt to scrape are controlled by JavaScript and Google Sheets can't understand/import JS. You can test this simply by disabling JS for a given link and you will see what exactly can be imported into Google Sheets:

enter image description here

  • Oh, and do you know if is there any other approachment to do that without leaving Google Sheets? – Marcos Martínez Jun 21 '19 at 14:30
  • your only option is to find another (non-JS) site which has what you want and scrape that – user0 Jun 21 '19 at 14:32

Google Sheets built-in IMPORT functions are only able to import data that is included on the source code of the file (web page, xml, css, rss feed, etc.) One alternative instead of using IMPORT functions use the GOOGLETRANSLATE built-in function but bear in mind that it only return translations, not transliterations.

To ask for a software recommendation, please post a question on https://softwarerecs.stackexchange.com

If you are a programmer or able to learn about using APIs take a look to Translate API maybe it could help to get what you are looking for.

  • Sadly, the GOOGLETRANSLATE built-in function is unable to add phonetic guides, it just translate the text onto other languages. – Marcos Martínez Jul 23 '19 at 7:47
  • @MarcosMartínez Thanks for the feedback. I slightly modified my answer. – Rubén Jul 23 '19 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.