How to translate the files using google translator via selenium - java

I came across https://translate.google.com/ which translates given text to the desired language.
I have nearly 2,000 files, each file 300 KB.
Currently I need to open each file, paste the text and translate it by above web-site then save it.
Is there a way to automate for the 2,000 files by reading and sending portions of files and finally append to the files? Repeat same for all files.
Doubts:
Will the IP address be blocked?
Is it illegal to use selenium for this purpose?
Is there a legal automated way to translate using the above free service?
If nothing is possible, I need to do it manually.
please advise.
thanks.

1- I think not
2- No, its no illegal
3- Yes, you can use the google translate api:
https://translate.googleapis.com/translate_a/
single?
client=gtx
&sl=<SOURCE LANGUAGE, can be auto>
&tl=<TARGUET LANGUAGE, cannot be auto>
&dt=t
&q=<TEXT>
References: https://cloud.google.com/translate/

I recommend you to check the Google API Cloud Translation:
https://cloud.google.com/translate/docs/
and the REST API reference:
https://cloud.google.com/translate/docs/reference/rest/

Related

Change ASP to Java technology?

I need help on how to propose a new website. I don’t know how to start and I hope you can guide me( if it is better to make an applet , a servlet, use other technology, etc. ) .
I have a website in ASP, it reads text files that are on the server in the same directory as the web . There are n files (may be about 300 plain text files generated by an external application ) . The website only read them, generates a menu with the data they contain . Depending on the selected menu options , read a specific files and pass this information to Flash movies which generate statistical graphs.
Flash movies are very old and actually cause problems in browsers. They can’t be loaded on all platforms for example. And the ASP technology is also obsolete.
We want to change the technology and create a web that reads a series of text files hosted on the server and pass these parameters to a graphic (we would use javascript libraries, for example Morris). We are interested for JAVA. What you recommend?. if its JAVA , this can be done with Applets ? or Should we use servlets?? or Is there an easier way to do it?
I use amcharts (http://www.amcharts.com/) to generate our charts.
I build the data using classic ASP ... then pass to an array in JS and then use the amcharts tools, which are very powerful and flexible.

how to convert a HTML web page into a PDF file using Java

i've been searching on the internet on how to convert a HTML page into a PDF file using Java. i found a lot of pointers, and in short, they don't work or are too difficult to implement. i also downloaded a commercial product, pdf4ml; the API is something i'd be happy to work with, except that when i crawled a simple page on wikipedia, i get a out of memory error (setting Xmx to 1024 M). in some approaches, they suggest converting HTML -> XHTML -> FO -> PDF. however, i am getting a lot of exceptions for the XHTML-to-FO XLS file; and reading the documentations, it's not something that i have enough time to understand right now.
here are my questions/concerns.
1. is there another cohesive API out there that will easily convert HTML to PDF (commercial or not)?
2. is there a way i can simply capture a HTML page and store it as a single file. this approach would be similar to using internet explorer's way of saving a web page as a web archive (single file, MHT format)?
any help is appreciated. (btw, i know this question has been asked repeatedly, but in addition to the original spirit of the question, i'm opened to other ways). thanks.
Try wkhtmltopdf, which is using WebKit. Another option (I'm using that currently) is using OpenOffice (remote controlled via macros).
you may use iText open source Java lib for that, and read this
or use YaHPConverter open source Java lib.
or do this whith help of icepdf popular open source lib
or use pd4ml, but it not free, only trial.
or use this, and this is man for it.
My 2 cents using opensource tools:
You can use either Capture screenshots with Selenium or WebDriver to save html page's screenshot in an image file from your Java code. And once you have image file you can convert it to pdf again from your Java code.
EDIT:
It seems you can do all that in 1 step using itext Html to Pdf
I am not sure but you could Try
1) cobra html rendering engine http://lobobrowser.org/cobra.jsp
2) htmleditorkit -- part of jdk
3) JWebPane
Use the rendering kit to parse and render html. The rendered out put is a swing component. Swing component can be used by itext to generate pdf file out put
You can try out Pdfcrowd. It is an easy to use commercial online API with many options and with support for Java.
It can create PDF either from web pages or raw HTML code.

How to create a desktop application to mimic what I've already written in PHP?

just looking for a point in the correct direction..
So I've developed a little application on the back end of our websites that allows the girls in our office to send out letter-headed PDF quotations to our potential clients via email.
I've done this using a simple HTML form, the FPDF class, and the php function mail()
It works a treat, but I'd like to take it a step further and create a desktop application so that the girls don't have to go through the login section of the website to access this functionality.
I'm thinking Java?
Would this be a difficult mission someone who has only had web-developing experience?
It would only be the smallest/simplest of applications.
Thanks for any input :)
This is just an advice.
Since you have already developed something that works over web, reuse it.
Convert the PDF converter into a service to upload and retrieve file. This service should return a token_id that can be used later to download the converted files.
Write a Java app using Swing that merely uses this web service. The logic in this application should be (a) browse file from computer, (b) Use web-service upload URL to upload the file and rec/eive appropriate response like upload_token_id and status uploaded/converted/failed, (c) the Java app, should be able to use this token to download the converted file.
You may need to look into this for help related to uploading the file
No it wouldn't be difficult job to mimic your app to java desktop app that can be Java Swing APP. you just need some practice on swing. As you are doing in php that is creating PDF and mailing it. This task can easily be done in java swing by using Java Mail API for emailing and IText for pdf generation.
For reference you can read following links:
http://www.javabeginner.com/java-swing/java-swing-tutorial
http://zetcode.com/tutorials/javaswingtutorial/
http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/
http://www.oracle.com/technetwork/java/javamail/index.html
http://java.sun.com/products/javamail/javadocs/index.html
http://www.javacommerce.com/displaypage.jsp?name=javamail.sql&id=18274
http://viralpatel.net/blogs/2009/04/generate-pdf-file-in-java-using-itext-jar.html
Hope this helps.

How to perform: Upload Image > Recognize Text > Make Image Searchable > Store into DB?

I need to know how to perform the procedure, you already have read in the title.
You'll upload an image (e.g. a piece of text, an article) and on server-side the text will be recognized via OCR and stored into a database.
Which would be the best programming language for it? It should be a browser application.
I found the ocropus project, but how can I combine it to common web scripting languages like PHP? Is it possible at all? Didn't have worked with Python yet.
Or a totally different approach..? Java Enterprise?
Let's rock that,
Chris
maybe you can use this php library i use for recognize text from images and store the text readed into database
http://www.phpclasses.org/browse/package/2874/download/targz.html
download the rar package and run example.php and then example1.php to see how it works
here you have an image upload example:
http://www.reconn.us/content/view/30/51/
hope this helps

How to Refresh Excel Data Source Via Java

I have an excel file that pulls in data via data connection from bunch of CSV files. The CSV files are generated every now so often by a JAVA program.
Is it possible to refresh the data too via. JAVA program? I see JXCELAPI and JOI are there, but briefly looking at their documentation doesn't indicate my use case is even possible.
In short, I need API that could achieve this effect: clicking on menu Data->Refresh All.
Thanks,
_Madhu
You could try XLLoop. This lets your spreadsheet talk directly to a java server (or a number of other languages) via function calls.
So you can have your spreadsheet call eg GetMyData("somedata") and it will load the data directly from your server whenever you re-calc (ie. Shift-F9).
BTW, I work on the project so let me know if you have any questions.
This tutorial sounds like it might help: Accessing Excel from Java
You could also try Obba which is another solution to access a Java library via Excel cell functions (UDFs)...
However, what you describe could also be done by a very small vb/vba macro which checks/polls for modification of these CVS files. I don't know if this is suitable in your situation, but there is an event listener for that: http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.changed.aspx#Y0

Categories