I am trying to execute this method with IronPython on .NET 4.0 using IronPython 2.7. i am using Windows 7
import os
import re
import nltk
import urllib
import xapian
import sys
def getData(url):
try:
html = urllib.urlopen(url)
text = html.read()
html.close()
except:
return "error"
try:
return nltk.clean_html(text) #takes the tokens
except:
return text
C# CODE:
public static object Execute()
{
string scriptPath = "Calculator.py";
ScriptEngine engine = Python.CreateEngine();
engine.SetSearchPaths(new string[] { "c:\\Python26\\lib","c:\\Python26\\lib\\site-packages",
"C:\\IronPython-2.7\\Lib\\site-packages","C:\\IronPython-2.7\\Lib"});
ScriptSource source = engine.CreateScriptSourceFromFile(scriptPath);
ScriptScope scope = engine.CreateScope();
ObjectOperations op = engine.Operations;
source.Execute(scope);
dynamic Calculator = scope.GetVariable("Calculator");
dynamic calc = Calculator();
return calc.getData("http://www.wowebook.com/dot-net/ironpython-in-action.html");
}
Can someone tell me what I am doing wrong? I keep gettin that i do not have fcntl module