Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Download webpage

If you have a question or need help, this is the place to be.
Post Reply
zetat
Posts: 8
Joined: Thu Aug 29, 2013 5:29 pm

Download webpage

Post by zetat »

Hi,
I want to create a python script that download https://api.trafiklab.se/sl/realtid/Get ... 0&key=XXXX
and save it to: C:\inetpub\wwwroot\eg\xml\test.xml

Have anyone any idea how to fix it?
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Download webpage

Post by Pako »

zetat wrote:Have anyone any idea how to fix it?
I'm not sure I understand.
I thought the "FIX" is used when something is broken.
However, try to use the action "Python Script" with the following code:

Code: Select all

import codecs
import urllib
url = r"https://api.trafiklab.se/sl/realtid/GetDpsDepartures.xml?siteId=4239&timeWindow=30&key=XXXX"
filePath = r"C:\inetpub\wwwroot\eg\xml\test.xml"
page = urllib.urlopen(url).read().decode('utf8') 
file = codecs.open(filePath, 'w', 'utf8')
file.write(page)
file.close()
Pako
zetat
Posts: 8
Joined: Thu Aug 29, 2013 5:29 pm

Re: Download webpage

Post by zetat »

Thanks alot it worked. :)
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: Download webpage

Post by zian »

Pako ROCKS some python!!!

Love ya man. ;)
eventghost.net
Be there or be square.
Post Reply