if I try to load the data using below script, the html code is being loaded instead of proper data. The given link leads to the direct source of xlsx or csv file (if you run that link in the browser, the xlsx or csv file will start downloading automatically). I would be glad to hear why this kind of situation happens and how to love this problem.
如果我尝试使用下面的脚本加载数据,则加载html代码而不是正确的数据。给定的链接指向xlsx或csv文件的直接源(如果在浏览器中运行该链接,xlsx或csv文件将自动开始下载)。我很高兴听到为什么会出现这种情况以及如何爱这个问题。
import clr
clr.AddReference('System.Net')
from System.Net import HttpWebRequest, NetworkCredential
from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings
readerSettings = TextDataReaderSettings()
readerSettings.Separator = ";"
readerSettings.CultureName = "en-GB"
req = HttpWebRequest.Create("some link to xlsx file")
user_agent = 'individual user-agent'
req.UserAgent = user_agent
req.Method = "GET"
req.UseDefaultCredentials = True
#req.PreAuthenticate = True
user = Document.Properties["Username"]
password = Document.Properties["Password"]
req.Credentials = NetworkCredential(user, password)
rsp = req.GetResponse()
dSource = TextFileDataSource(rsp.GetResponseStream(),readerSettings)
rsp.Close()
dataManager = Document.Data
dataTable = dataManager.Tables[document.Name]
dataTable.ReplaceData(dSource)
1 个解决方案
#1
0
the important part of the HTML returned isn't "Javascript is disabled", it's "We can't sign you in because Javascript is disabled." based on this it sounds like your issue is that you haven't properly authenticated your session.
返回的HTML的重要部分不是“Javascript被禁用”,它是“我们无法登录,因为Javascript被禁用”。基于此,听起来您的问题是您没有正确验证您的会话。
I would try to validate by loading this code into the Python IDE of your choice and try it independent of Spotfire.
我会尝试通过将此代码加载到您选择的Python IDE中进行验证,并尝试独立于Spotfire。
the correct way to access Sharepoint, most likely, is through the Sharepoint API. I don't have experience with this but I'm sure some googling could turn up a solution. once you have a (third-party library free!) solution working in Python, you can adapt it to Spotfire without too much trouble.
访问Sharepoint的正确方法很可能是通过Sharepoint API。我没有这方面的经验,但我确信一些谷歌搜索可以找到解决方案。一旦你有一个(第三方库免费!)解决方案在Python工作,你可以适应Spotfire而不会有太多麻烦。
#1
0
the important part of the HTML returned isn't "Javascript is disabled", it's "We can't sign you in because Javascript is disabled." based on this it sounds like your issue is that you haven't properly authenticated your session.
返回的HTML的重要部分不是“Javascript被禁用”,它是“我们无法登录,因为Javascript被禁用”。基于此,听起来您的问题是您没有正确验证您的会话。
I would try to validate by loading this code into the Python IDE of your choice and try it independent of Spotfire.
我会尝试通过将此代码加载到您选择的Python IDE中进行验证,并尝试独立于Spotfire。
the correct way to access Sharepoint, most likely, is through the Sharepoint API. I don't have experience with this but I'm sure some googling could turn up a solution. once you have a (third-party library free!) solution working in Python, you can adapt it to Spotfire without too much trouble.
访问Sharepoint的正确方法很可能是通过Sharepoint API。我没有这方面的经验,但我确信一些谷歌搜索可以找到解决方案。一旦你有一个(第三方库免费!)解决方案在Python工作,你可以适应Spotfire而不会有太多麻烦。