簡體   English   中英

使用 Python 3.5.2 將 ServiceNow 數據下載到 CSV 文件中

[英]Downloading ServiceNow data into a CSV file using Python 3.5.2

有人可以告訴我如何將 SOAP 和 WSDL 功能與 ServiceNow 一起使用,以便將數據下載到 CSV 文件中。 我正在使用 Anaconda 版本 3.5.2

一個示例腳本會非常有幫助

降級不是我的選擇。

我的工作中還需要下載和處理服務即時報告。 您可以使用SOAPRESTWSDL 我正在使用REST 不確定這是否會有所幫助。

您需要在表名后postfix下載類型。 例如下面示例中的CSV 報告 URL 的其余部分與您從servicenow手動下載報告相同。

這是一個下載CSV格式報告的工作代碼。 報告 URL 和 ID 將需要根據您的組織進行更改。

import requests
import getpass


url = "https://yourcompany.service-now.com/sys_report_template.do?CSV&jvar_report_id="1234567890abcdefg"

uname=raw_input("Enter Username: ")
pswd=getpass.getpass(prompt='Enter Password: ', stream=None)

r=requests.get(url, auth=(uname, pswd))



if r.status_code==requests.codes.ok:
    print("Requests made a connection.\n")
    f=open(r'C:\dump.csv', 'w')
    f.write(r.content)
    f.close()

else:
    print("\nAn error occured while establishing a connection.")
    print("Status code returned: ",r.status_code)

c=input("\nEnter a key to exit.\n")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM