-1

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

For instance, if you enter the page:

https://translate.google.com/#view=home&op=translate&sl=auto&tl=zh-CN&text=欢迎你

…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?

2 Answers 2

0

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

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

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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