Over a million developers have joined DZone.

Python - Query BabelFish

·
//Example di POST HTTP


#!/usr/bin/python

import urllib

def translate(lang='it_en', text='ciao'):
	
	'''Converte delle frasi da una lingua sorgente ad una lingua destinazione'''

	url = urllib.URLopener()
	
	query = urllib.urlencode({'doit':'done', 'intl':'1', 'lp':lang, 'tt':'urltext', 'urltext':text})
	
	responde = url.open('http://babelfish.altavista.com/tr', query).read()

	start = responde.find('
') + 25 stop = responde.find('
', start) print responde[start:stop]
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}