'''
Created on Jan 29, 2016

@author: Martin Koerner <info@mkoerner.de>
'''

# https://github.com/Mimino666/langdetect
from langdetect import detect 
from bs4 import BeautifulSoup
import urllib

url = 'http://bund.de'
html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)
html_body = soup.body.get_text(" ")


print detect(html_body)

'''
Created on Jan 29, 2016

@author: Martin Koerner <info@mkoerner.de>
'''

# https://github.com/Mimino666/langdetect
from langdetect import detect 
from bs4 import BeautifulSoup
import urllib
import argparse

# generate help text for arguments
parser = argparse.ArgumentParser(description='Extracts languages from a list of Websites given by their URL')
parser.add_argument('input',
                   help='a file path to the output file generated by this program')
parser.add_argument("--output", dest="output", metavar='output path', type=str)
args = parser.parse_args()

inputfile_path=args.input
outputfile_path=args.output

output = open(outputfile_path, 'w')

for line in open(inputfile_path,'r'):
    line=line.rstrip('\n')

    url = line
    html = urllib.urlopen(url).read()
    soup = BeautifulSoup(html)
    html_body = soup.body.get_text(" ")
    language=detect(html_body)
    print line+" --> "+language

    # TODO write as json
    output.write(line+"\t"+language+"\n")

output.close()
Add argparse and file iteration to website_language_extraction