|
|
Comments and Discussions
|
|
 |

|
Thanks for your reply.
> As a worst case scenario, your C++ app could slave a .NET app to do the translation
Briefly, how would I do that?
Or I guess I could replace GoogleTranslator.cs with a C++ version. But how would I reference the DLL?
Sorry, I only know C++ and MFC, not C# and .NET.
I would appreciate any guidance you can give as I am very keen to use this code.
David
|
|
|
|

|
Ravi, please will you give me a hint as to how to modify this C++ version to use a proxy? Does it use an underlying MFC class that I can instruct to use a proxy server?
|
|
|
|

|
I enabled proxy server compatibility by changing line 69 of AmHttpSocket.cpp from:
hIO = InternetOpen(m_strAgentName, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
to
hIO = InternetOpen(m_strAgentName, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
works for me under Win XP SP2.
See: http://msdn.microsoft.com/en-us/library/aa383996(VS.85).aspx
|
|
|
|

|
Thanks, David! I'll update the article.
/ravi
|
|
|
|

|
Does the CWebResourceProvider class work in Unicode builds?
|
|
|
|

|
Hi Hans,
It will need to be modified (_T(), etc) to support Unicode. There's no reason why this can't be done, but it doesn't support Unicode currently. The .NET version (see my other articles) obviously supports Unicode out of the box.
Thanks,
/ravi
|
|
|
|

|
OK, thanks for the quick reply. Do you have a later version that has support for proxies? I don't see that on the history list.
|
|
|
|

|
Hans Dietrich wrote: support for proxies?
That's still on my to-do list...
/ravi
|
|
|
|

|
Ravi, thank you for the useful code.
However, it would be really nice if you could have a C++ Unicode version. Otherwise you cant translate to Chinese for example. Now you might think doing so is simple, a few defines, but no.... I see that your code relies on InternetReadFile, as does some of my mine, but there is no InternetReadFileW! There is a InternetReadFileExW but it works differently and I have yet to track down a working example (which is how I stumbled on this article).
If a web page returns Unicode, then InternetReadFile will convert it for you, which does not work that well for some languages.
If you could make a Unicode version, you would a hero!
|
|
|
|

|
Thanks for your comments!
Unfortunately I'm severely cycle disadvantaged right now Btw, there's a .NET version of this class @ CP if you'd like to use it. Free Unicode, etc.
/ravi
|
|
|
|

|
On a similar project I was working on, I had to get Unicode translation to work in C++, and I was using Google translator.
I finally figured out that with Unicode you still use InternetReadFile BUT you typically have to use MultiByteToWideChar(CP_UTF8,... ) to convert the content to Unicode wchar_t. Assuming it is UTF-8 this works fine and you get nice chinese characters which you should be getting. If the returned text really is just plain ascii, then MultiByteToWideChar does no harm (MSDN confirms this).
I guess the general approach to use is to use the API function which tells you if the returned buffer is Unicode or not, and if not, convert it to Unicode using MultiByteToWideChar. In theory you may be able to get hold of the headers which may tell you, but I had little luck doing that.
Sadly the above is the result of several hours of struggling and colourful language.
|
|
|
|

|
I assume you're forced to code this in C++?
/ravi
|
|
|
|

|
For instance, I choose the translater everytime I run it, pops up " Unable to translate text." Looking forward to your respond
Thank you in advance.
Cheers,
Ryan
|
|
|
|

|
I wanna clarify, the zipcode button works properly.
The other three buttons dont function.
Thank you.
Cheers
|
|
|
|

|
Thanks, I'll look it into it.
/ravi
|
|
|
|

|
Hi, I have this webpage that needs log in. <i><FORM name='fid' METHOD=post ACTION='/cgi/cgiwrap/blabla/blabla.cgi'> <INPUT TYPE=hidden NAME=do VALUE='show'> <INPUT TYPE=hidden NAME=cour VALUE='305'> <table width=380 border=0 cellpadding=2><tr> <td align=right> Year: </td> <td align=left> <SELECT NAME=year> <OPTION VALUE=00 >2000 </OPTION><OPTION VALUE=01 >2001 </OPTION><OPTION VALUE=02 >2002 </OPTION><OPTION VALUE=03 >2003 </OPTION><OPTION VALUE=04 >2004 </OPTION><OPTION VALUE=05 >2005 </OPTION><OPTION VALUE=06 >2006 </OPTION><OPTION VALUE=07 selected >2007 </OPTION><OPTION VALUE=08 >2008 </OPTION> </SELECT></td> <td align=left rowspan=3><input type=submit value=" FETCH "> </td> <tr> <td align=right> Student ID: </font></td> <td align=left><input type=text NAME=id MAXLENGTH=7 SIZE=7></td> <tr> <td align=right> Password:<br><FONT size="-2"> </font></td> <td align=left><input type=password NAME=pw MAXLENGTH=12 SIZE=7></td> <tr height=8> </table> </FORM> </i>
I have the username and password but I don't want to do it by myself, I want to do it automatically and get the source code after the log on. In the article it says I can handle it POST methods but I don't know what to put into methods as a POST string. So I have a textbox named as 'id' and another txtbox named as 'pw'. I want to set their values and (perform) click to a submit button that posts these information to '/cgi/cgiwrap/blabla/blabla.cgi' and returns a web page whose source I desire. Since webpage that I'll call isnt obtained from querrystrings I couldn't do anything about it. What shall I do?
|
|
|
|

|
It seems I won't get an answer for that, I wish there were some simple examples about the subject
|
|
|
|

|
Sorry for the delay in replying - I'm currently away from home and don't have good internet access.
The POST string should contain:id=username&pw=password where username and password are the entered username and password.
/ravi
|
|
|
|

|
thanks but when I enter :
www.websiteaddress.com/cgi/cgiwrap/ae305/igrade.cgi?id=myid&pw=mypass
into the browser
the webpage returns :
"Illegal access" message..
I'm not sure whether my id and password can be passed in like this:
?id=myid&pw=mypass
as a querry string.
Anyways If I'm to put this information programmatically (and hopefully it won't give this message when I succesfully do somehow) should I use "WebClient.UploadString()" method?
|
|
|
|

|
methhoo wrote: into the browser
The browser passes these arguments as part of a GET request. You need to programmatically pass them in a POST.
/ravi
|
|
|
|

|
This article is nice. I need to read yahoo inbox is there any soloutions
Thanks in advance
Pandian
|
|
|
|

|
You'll probably first need to figure out Yahoo Mail's HTTP protocol. See this[^] Java implementation. Once you know the protocol, it should be fairly easy to use a WebResourceProvider derived class to implement a reader.
/ravi
|
|
|
|

|
Hi,
Thanks for the great idea, it perfectly worked for me.
I automated the posting to the google translator, i post around 200-300 text strings in a loop, get its translation and store in a DB, but looks like Google does not allow for automating this, and stops me from processing beyond 100-200 records.
Do you have any idea, if i can do this without any problem, should i add delays in my programs.
Thanks,
Akhil
|
|
|
|

|
Akhil Bhandari wrote: should i add delays in my programs.
Yes, that works.
My WRP apps ([1] and [2]) have baked-in pauses to ensure the target servers aren't overloaded.
/ravi
|
|
|
|

|
Hello,
The translator doesn't seem to work. Can you please fix this? Or give me some ideas on doing so.
Excellent work though, looking forward to your assistance.
Thanks,
Hitesh
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A framework to allow public web services to be used as objects in your application.
| Type | Article |
| Licence | CPOL |
| First Posted | 28 Apr 2002 |
| Views | 223,782 |
| Downloads | 1,553 |
| Bookmarked | 140 times |
|
|