I am trying to scrape a German website and I am in need to convert the scraped data from German to English. Now, What I did is I have hitted third party website to do this process for me. Hereby I have attached the code i tried as below:
from bs4 import BeautifulSoup, SoupStrainer
import urllib2
import urllib
import re
import sys
import string
import json
import socket
def translate(text_to_translate):
base_url = 'http://translate.reference.com/german/english/'
join_url = base_url + text_to_translate
request = urllib2.Request(join_url)
response = urllib2.urlopen(request)
soup = BeautifulSoup(response)
result = soup.find('textarea', {'placeholder': 'Translation'})
converted_text = result.string
return converted_text
text = "damen uhren"
text1 = re.sub('\s+', '-', text)
title_new = translate(text1)
print "Original String = ", text
print "Converted String = ", title_new
Is there a way to convert the german strings to english without hitting third-party websites? Is yes, please guide me through this.