Can I use Google Transliteration in Python? [closed] - python

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am aware that Google allows transliteration from English to several languages (www.google.com/transliterate).
I have an English word-list. I would like to transliterate (not translate) every word to Bengali (a language Google supports) - to obtain output in the form of a Unicode word-list.
Is there a way to use the transliteration API in Python to do this?

This is the getting started documentation: http://code.google.com/apis/language/transliterate/v1/getting_started.html#transliterateLowLevel
If you only need to use it one time, it's probably easiest to use the example code to perform your transliteration in a browser.
If you can figure out the actual requests to make (shouldn't be hard, you can observe them in your browser's developer tools), you can re-implement that using the requests module (just get it with pip).

Try the unidecode module

The Google Transliteration API is a javascript API meant to be used by web pages. There isn't anything about direct usage from programming languages or RESTful web services interface. This means that in order to use it from python, you would need to reverse engineer the calls made to the server (Not sure this is allowed though).
Another solution would be to use a Selenium web driver. You would need to install a browser and the Selenium web driver. Then, you would be able to control the browser from python (write text fields, read the results).

Also, there's https://github.com/davisp/python-spidermonkey found in Best way to integrate Python and JavaScript?. At least a place to start looking.

Related

Building HTML5 based GUI in python [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Recently I was at a conference and one company had a software product which had a GUI written in HTML 5.It was rendered to the user via their custom built browser and looked quite good. I never heard of such concept and I am wondering if this is a common practice? I can see some benefits being able to produce flexible and stunning UI designs. Are there any tools available in Python? I assume you just need a browser able to render static pages with HTML and CSS. Also what would be the disadvantages of such approach?
This is the closest I found https://github.com/html5lib
If you're going to send it in HTML5, I see no reason to build a browser though, there are already many browsers, that have more people working on them, you'd be hard pressed to beat something like Firefox or Chrome, unless you have a specific feature you want, and then a plugin might be better. Generally building a custom browser like that is only useful if you either only want to do one very limited thing (like streaming a movie) or you want to use a different format (something like sending your version of HTML in an XML doc and parsing that and rendering it).
I also personally don't think Python is what you want to do this with, simply for a lack of compatibility with pretty much everything else at the current moment (not that you couldn't make things work, but it's not like you're going to download a Chrome plugin, change 3 lines of code and load it into your browser). I did see an example web browser in the wxPython docs, you could start there, I don't know what it does and what it doesn't do though unfortunately.

Can I visit a webpage many times with a new IP address each time using Python? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I know, using Python, a webpage can be visited. But is it also possible to visit a webpage with a new IP address each time?
You cannot change your IP via python.
Try installing TOR and then use Proxychains to pipe your script /requests via the TOR network, though the ip will be kinda random everytime
If your script is called getit.py and you have TOR/Proxychains setup correctly then you can send anything through the TOR network. Eg.
Chrome:
proxychains google-chrome
getit.py:
proxychains python getit.py
or
proxychains getit.py
Everytime you run the script you will have a different ip. Well to be correct not everytime but proxychains will respect your TOR Config so, everytime is relevant to that.
Also not only everytime you run the script but also everytime the script tries to access a resource. Again related to TOR config.
Do an online search for a listing of "Proxy services" from the internet. You can then loop through them as proxies in Python. There are companies that maintain open proxy networks , and across multiple continents , to help people get past GEO-IP restrictions.
You can also configure different servers you control on the internet to act as remote proxies for your needs.
Don't use TORĀ for this project, which has legitimate uses and needs... and has bad bandwidth already. There are rarely any legitimate uses for doing stuff like this.
There are also shady publishers of "Open Proxy" lists - basically a daily updated list of wrongly configured apache instances that can reroute requests. Those are often used by people trying to increase ad impressions / pagecounts or fake online voting contests. ( which are the two main things people want to do with open proxies and repeated 'new' visits )

Can API hooking in python be OS agnostic? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
In the world of penetration testing with Python, it looks like
one has to generally hook into an API that's OS specific. This makes sense
to me because we're dealing with different architectures and kernels between
OSX, Linux, Windows. But I'm wondering if this isn't the case?
Beyond some of the limited functionality you get out of the OS module, my assumption is that hooking into the OS's API is general going to be specific to *POSIX flavor (maybe they have more in common) than in Windows for example.
In particular I'm thinking of Deviare on Windows. It deals with .DLL files. That's pretty much Windows.
The moment we hear DLL, the mind goes to windows land, .plist OS X and so on.
Hooking is a way to get your own code to execute when another system is running, whether that other system is an OS, a GUI, or whatever. A somewhat silly example in Python:
def Process(records, per_record_hook=None):
"adds all records to XYZ system"
XYZ = []
for record in records:
if per_record_hook:
per_record_hook(record)
XYZ.append(record)
def print_record(record):
"print a '.' for each record (primitive counter)"
print '.'
and then later:
Process(records_from_somewhere, per_record_hook=print_record)
http://en.wikipedia.org/wiki/Hooking
I'm going to assume you're referring to this ^ kind of hooking? I'm completely unfamiliar with the term, but it seems like you're looking for a library that allows interactions with the operating system?
If so, try something like PyWin32 (google it) or follow some of the techniques found here:
http://www.rohitab.com/discuss/topic/37018-api-hooking-in-python/
Again, it'd be more helpful if you could put it (the phrase hooking) into more...Python-esque terms, but I hope this helps?
In Python things like this is generally so trivial that it's hard to even provide examples. Hooks are generally callbacks, yes. Callbacks in python are simply done by passing functions around and calling them.

Web interface for a Python code [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
first, English is not my native language, so, forgive me for any mistake.
I don't want to make a evasive question, so i will detail my scenario and make my point below:
I need to make a Web interface to take a information from a html's form field. Specifically a text file. Then, i need to give this file as a paramater to a Python Script that will run on my Linux server (the same who was the Web interface). I have the script running okay, have the Web interface ready, but i didn't get the point to make the web stuff works.
I'm stuck on the part of "make the wweb form talks with python script".
I tried some linux commands and some tips found on my research, but didn't work.
The goal of this thing, is to not send the Python code to end-user. So, the clients will "use" the code from a web interface and will not see the Python code responsable for make the hole stuff works.
Does anyone ever seen this kind of implementation?? Any help or information will be nice ! Tks a lot !
You should probably start with this page from the Python documentation - http://docs.python.org/howto/webservers.html. This may give you some ideas about how this works, and depending on what you need you may then continue reading about more detailed topics. Solution will depend on your plans for further development (will you extend the logic of this application? will you connect to the DB, etc.), security concerns, etc.
For only the case you define, it sounds like some simple solution will work for you, like having a simple CGI script ( http://docs.python.org/library/cgi.html), and you probably don't (yet) need anything powerful like Django or TurboGears.
For CGI to work, you will need to configure Apache web server, enable CGI for it, and then implement the CGI script utilizing your already implemented program.
You may check on the web how to do each of those steps. For example, right here, on stackoverflow: How do you set up Python scripts to work in Apache 2.0?
In your CGI script, you will need to implement some logic which will allow users to upload files to your server. You may check this page for that: http://code.activestate.com/recipes/273844-minimal-http-upload-cgi/
Finally, if with time you plan to further develop your application, you may want to look to something like Django or TurboGears. The more complex your application is - the better it is to use some web framework. You will probably spend more time studying those, but in the end you get much more power with them, and you get the code which is much more easier to maintain compared to CGI scripts. But, just as I said - it depends on your needs. (Although studying them is a good idea anyway ;) )

How To Use Python for a Web App? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am creating a school management system that handles file uploads and downloads from teachers and students. Furthermore, there will be a large amount of database writes and reads (e.g. which classes a student is taking, what the student's grades are etc.)
I want dynamic web pages updated with python using an AJAX model on the front end.
On the back end I want to use python for file handling, database reads to show user their content, database writes when a user updates his/her content on the web app and memcache.
The stack I am using is...
CentOS + Hadoop + Hypertable + Python
I am currently going through the Pyramid docs and after going past a few chapters, I don't see how pyramid helps me accomplish what I can do in PHP, and if it does do this, why so complicated?
Is pyramid the right tool, or should I be using web2py?
If pyramid is the best tool, where can I see some sample code of a complex application built in pyramid. I tend to understand best when reading other's code.
Django cannot be used due to inflexibility
I don't see how pyramid helps me accomplish what I can do in PHP, and if it does do this, why so complicated?
A web framework like Pyramid is not a web framework like PHP. They're different.
Complexity is a matter of "experience". If you're experienced with PHP, Python seems complex. If your experienced with RoR, PHP seems complex. Everything that's new seems complex.
Python has a dozen or so web frameworks of varying capabilities. None of them will look like PHP. Zero. They'll all be different (and appear complex).
Consequently, if you don't like one. Move on. There are a lot of choices. Keep trying different ones.
Ask specific questions. "I don't see how pyramid helps me accomplish what I can do in PHP" is too vague to discuss further. If there's a specific thing you want to know about, search for that specific question (it's probably already been asked). If you don't find anything, ask the specific question. Code samples help.
I highly recommend you use Django.
https://www.djangoproject.com/
Django is a great way to do a project like this, and the documentation is outstanding. There is a free book, called The Django Book, which you can read online.
http://www.djangobook.com/
This book is a few years out of date. I haven't been keeping up with Django but I am pretty sure that the book will still be useful. Use the book to learn the concepts, and use the actual Django documentation to look up specifics.
I've had some great luck with Django, its pretty well documented and has examples that do exactly what you seem to do

Categories