Return to Snippet

Revision: 1732
at November 10, 2006 00:09 by whitetiger


Updated Code
import string, urllib

def clean(text):
	return ' '.join(string.replace(text.strip(), "\n", ' ').split())

def translate(frase, da, a):

	frase = clean(frase)

	params = urllib.urlencode({'BabelFishFrontPage':'yes','doit':'done','urltext':frase,'lp':da+'_'+a})

	response = urllib.urlopen('http://babelfish.altavista.com/tr', params)

	import time
	print params
	time.sleep(1)

	f = open("prova.html","w")

	html = response.read()

	f.write(html)

	f.close()

	print html

Revision: 1731
at November 9, 2006 23:54 by whitetiger


Initial Code
import string, urllib

def clean(text):
	return ' '.join(string.replace(text.strip(), "\n", ' ').split())

def translate(frase, da, a):

	frase = clean(frase)

	params = urllib.urlencode({'BabelFishFrontPage':'yes','doit':'done','urltext':frase,'lp':da+'_'+a})

	response = urllib.urlopen('http://babelfish.altavista.com/tr', params)

	import time
	print params
	time.sleep(1)

	f = open("prova.html","w")

	html = response.read()

	f.write(html)

	f.close()

	print html

Initial URL

                                

Initial Description

                                

Initial Title
Python - Query BabelFish

Initial Tags
http, file, html, post, python, style, text, apache, web, color

Initial Language
Python