Getting Google Translate's html codes in php - php

after reading these in below, I still can't see the solution :
Extract data from website via PHP
php extract body tag content
after i using
file_get_contents("https://translate.google.com/#view=home&op=translate&sl=en&tl=fa&text=Help%20Me")
It seems it doesn't contain the words that I typed in box of translator(the words:Help Me)
How can i get all the data from start to end that contains the word that user(myself) typed?

Google Translate uses Javascript to read & display the translated text. It is not available in the source code. You can verify this by viewing the source of the URL you provided yourself (e.g. by copying view-source:https://translate.google.com/#view=home&op=translate&sl=en&tl=fa&text=Help%20Me into your address bar). It's also against their terms of service.
To access Google Translate programmatically you need to use the Cloud Translation API. This API provides $10/month of free usage, which is enough for most hobbyist projects.
Here is more information on pricing and quotas, and even a handy guide to using PHP with it.

Related

Delphi: How to get data from this website?

I'm trying to get data from a website:
http://site2.aesa.pb.gov.br/aesa/monitoramentoPluviometria.do?metodo=listarMesesChuvasMensais (translated via Google Translate)
In Delphi I know working with XML based Webservices (SOAP, WSDL), but this site does not provide such kind of services.
But I do not have knowledge in languages ​​like PHP and HTML, not even web languages ​​in general.
My question is, is there any way to get data from that site with the knowledge I do (not) have? Is there a tool to do this in Delphi? What are the common first steps to study the ability to do this?
Input January and 2014:
http://site2.aesa.pb.gov.br/aesa/monitoramentoPluviometria.do?metodo=listarMesesChuvasMensais
Output:
a generic method url
http://site2.aesa.pb.gov.br/aesa/monitoramentoPluviometria.do
First you need to use a HTTP client such as Internet Direct (Indy) or Synapse to get the web page as text.
Then you can either a HTML parser library or plain string routines to extract the table data.
How to perform HTTP requests is shown in many articles and Stackoverflow questions.

Could I know what has been changed lately in the file?

I'm doing some development and my company does use excel to edit database (I don't agree but, hey... hate the game, not the player! :D ). So, to avoid some encoding problems, I aiming to put it to Google Drive because it's very unlikely to change this sort of things the Microsoft insists in change every d**m version.
What I'm trying to do is: receive a file from Google Drive with only the fields that has been lately manipulated (or even receive the entire file, but somehow I could know the last changes), put it on a variable and manipulate it. I don't have the need to edit de excel file itself. It's going to be on Google Drive's interface. I only need to read it.
NOTE 1: I was using this doc (https://developers.google.com/drive/manage-changes) , but it appears that the API only says if either the file has been changed or not. I would be very nice if I could know what has been changed in the file. It would avoid me a overload in the database (I'll have to re-write the ENTIRE DATABASE).
It's impossible to retrieve field changes, but you can retrieve a change history by listing changes.
https://developers.google.com/drive/v2/reference/changes
You probably want to check Revision.
Google Drive provides file revision and you can get list of changes using this API

Google Kix editor - how to send data using POST?

Can I include this text editor for Google Docs to my project?
https://github.com/benjamn/kix-standalone
or this is illegal?
I suspect that this person just steal the code. If this legal how can I send the data using POST to PHP? The HTML code does not have a textarea to send it, and I couldn't find a way to send the data.
I think it's illegal because this code is not provided by Google. One reason is that it is heavily based on server-side components see this
https://groups.google.com/forum/?fromgroups=#!topic/closure-library-discuss/SeZdenR-2vA
and the link you provided contains the obfuscated code and you will have no support if you use it.
hope this help

How to download information from a website

I'm trying to automatically download information from a website based on a few parameters. Essentially I want to specify the parameters of a search and have the function automatically navigate to the appropriate website and download the file. Note that all of the files are excel file, usually .csv.
Here's the website:http://comtrade.un.org/db/
NOTE: This websites address will be updated depending on the search, so, for instance, if you search trade from the united states to iran (The rest of the parameters are unspecified), the result is:
http://comtrade.un.org/db/dqBasicQueryResults.aspx?px=HS&cc=TOTAL&r=364&p=842&rg=1&y=2010,2009,2008,2007,2006&so=8
More on this here:
http://unstats.un.org/unsd/tradekb/Knowledgebase/Data-Extraction-Using-Comtrade-Web-Service
Look under web service methods and parameters
Two Question:
1) How can I do this?
2) What is the best language to do this in?
There is just no "best language". You can do this by any language with HTTP access availability, this could be either PHP, Java, RoR, Perl, Python...
On the link you posted, you can read they are offering REST service for accessing the data in XML.
In PHP, you would first have to download the file using appropriate URL:
$xml = file_get_contents("http://comtrade.un.org/ws/...");
Than use PHP's XML functions to parse the file.
I'm not sure about their license of data usage - you might not be legally permitted to automatically download data from here.
UPDATE
You cannot directly download the files found in the search results (through PHP e.g.) - so you HAVE to use the REST access, but some parts of it are obviously accessible only if UN allow you to do so. If you would try to download directly the "excel" (in fact CSV) files, you will end up with error like this: http://comtrade.un.org/db/dqBasicQueryResultsd.aspx?action=csv&px=HS&cc=TOTAL&r=364&p=842&rg=1&y=2010,2009,2008,2007,2006&so=8. You can spoof the HTTP_REFERER value, but you will break the terms of the service.
In PHP, use file_get_contents("http://............");
Plug in whatever URL and GET parameters you want, and you instantly have the data, in this case the CSV, which you can then process.

Using Zxing online qr code decoder using php

I am creating a website that requires me to decode qr codes. I did my research and found out that php does not natively support decoding of qr codes. So, I decided to use the webservices that provide decoding of qr codes. I came across a good webservice, Zxing, which decodes the image submitted to it. The problem that I found was that I could not find enough documentation online with regards to the usage of the Zxing webservices, like how should the parameters be passed to the url of the webservice. The url that I am to access is, http://zxing.org/w/decode.jspx,
but then how should I consume this webservice using SOAP / XML-RPC in php.
I studied the result that is returned when I click on the "Submit" button, and its a simple text document.
Please, do give me guidance as to how should I consume the Zxing webservice, are there any online documentations?
Thanks.
It's not really documented as an API since it's not an API. You are not meant to integrate for use in your own service. It's a site I run as a free courtesy to end users on the web. It's OK to send a few requests at it, but for any significant volume, please run your own.
But the HTML is pretty much all the documentation you need: you can see what URL it posts to, and what parameters it sends. It's really just a POST of image content under parameter 'f', or a GET to the same URL with parameter 'u' specifying a URL to load.
The complete source code is at http://code.google.com/p/zxing, under zxingorg/. You probably want to run your own copy, so you can control it and modify it.

Categories