[英]How can I identify the language on a specific text using Selenium Webdriver
I'm new at this (only a week) and i've searched all over the net for this one. 我是这个新手(仅一周),我在网上搜索了这个。 I need to get the text and then identify the language that's written on, like in this case 'portuguese'.
我需要获取文本,然后确定所用的语言,例如本例中的“葡萄牙语”。
This is the div within the html I'm given: 这是我得到的html中的div:
<div class="episode-toggle" style="display: none;">
<div class="formattedTime">Hora de início/fim: 02:05 - 03:00 </div>
<div class="parental rating_R-10">Classificação Indicativa: 10<span class="path1"></span><span class="path2"></span></div>
<div>Sinopse: Playlist MTV é uma seleção com os melhores clipes
relacionados a um estilo musical específico. Acompanhe agora a melhor
seleção de clipes da música Pop.</div>
<div class="origin">País de origem: United States</div>
<div class="prodYear">Ano de produção: 2017</div></div>
This is what's on my selenium/java project: 这是我的selenium / java项目中的内容:
WebDriver driver = new ChromeDriver();
driver.get("http://www.mtv.com.br/horarios");
myString = driver.findElement(By.xpath("//div[@class='episode-toggle']")).getText();
System.out.println(myString);}
Any idea how can I do it (if there's any way) be it with selenium or other software? 知道如何使用硒或其他软件来实现它(如果可以的话)?
Thanks! 谢谢!
Try Google Cloud Translation API. 试用Google Cloud Translation API。 https://cloud.google.com/translate/docs/?csw=1
https://cloud.google.com/translate/docs/?csw=1
They have samples in Java to give you a start. 他们有Java示例,可以帮助您入门。
Im a python person and the sample has method detect_language which i think should suffice your requirements https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/translate/cloud-client/snippets.py 我是一个python人员,该示例具有方法detect_language,我认为它可以满足您的要求https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/translate/cloud-client/snippets.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.