Skip to content

Instantly share code, notes, and snippets.

@tcr
Created December 1, 2009 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcr/246496 to your computer and use it in GitHub Desktop.
Save tcr/246496 to your computer and use it in GitHub Desktop.
import urllib
import urllib.parse
import urllib.request
import sys
ip = input('Enter IP address: ')
path = input('Enter path to save data to (with trailing \): ')
while 1:
print('')
filename = input('Enter name for captured data: ')
# create request
url = 'http://' + ip + '/getwfm.isf'
# send request
sys.stdout.write('Capturing channel 1... ')
req = urllib.request.Request(url, 'command=select:ch1 on&command=save:waveform:fileformat spreadsheet&wfmsend=Get')
response = urllib.request.urlopen(req)
the_page = response.read()
# create a file object in "write" mode
file = open(path + filename + '_c1.dat', 'w')
file.write(the_page.decode())
file.close()
print('Done.')
# send request
sys.stdout.write('Capturing channel 2... ')
req = urllib.request.Request(url, 'command=select:ch2 on&command=save:waveform:fileformat spreadsheet&wfmsend=Get')
response = urllib.request.urlopen(req)
the_page = response.read()
# create a file object in "write" mode
file = open(path + filename + '_c2.dat', 'w')
file.write(the_page.decode())
file.close()
print('Done.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment