How do I go about checking if a user has a certain security level and
/ or a certain age? I mean what's the syntax of it? Thanks!!!
For reference, I am trying to grab the data found here: http://www.hamqsl.com/solarxml.php
For reference, I am trying to grab the data found here: http://www.hamqsl.com/solarxml.php
On 07/27/16, KenDB3 said the following...
For reference, I am trying to grab the data found here: http://www.hamqsl.com/solarxml.php
I didn't do this with java, but I thought you might get a kick out of the output:
.--------------------------------------------------------------------------- --. | Current Solar-Terrestrial Data, Updated: 28 Jul 2016 1424 GMT
| +------------------------------------------------------------------------- ----+ | Solar Flux Index : 71 Electron Flux : 4.41e+01 | | A Index : 4 Aurora
: 1/n=1.99 | | K Index : 2 Mag. Field (Bz)
: 1.8 | | X-ray : A5.8 Solar Wind
: 393.8 | | Sunspot Number : 0 Geomagnetic Field : QUIET | | Helium Line (304A) : 110.6 @ SEM Signal Noise
: S1-S2 | | Proton Flux : 2.10e-01 MUF @ Boulder, CO : 11.01 | +-----------------------------.---------------------------- .------------------+ | HF Conditions | VHF Conditions |`. \ ' / .'| | --------------------------- |
| `. .-*""*-. .' | | Bands Day Night | Aurora Lat : 67.5
|-._ /.*. .*.\ _.-| | --------------------------- | Aurora : Band Closed | : <x> <x> ; __| | 80m - 40m Fair Good | 6m EsEU : 50MHz ES |""': .. ; | | 30m - 20m Fair Fair | 4m EsEU
: Band Closed |-*" \ ____ / "*-| | 17m - 15m Poor Poor | 2m EsEU : High MUF | .' `-.__.-' `. | | 12m - 10m Poor Poor | 2m EsNA : Band Closed |.hamqsl.com/solar.| `-----------------------------^--------- -------------------^------------------'
ALCO-SOLAR v. 1.0 / by zERO rEADER / data from N0NBH
Everything is colorized "Amiga" style. The band conditions are colorized
the exact same way you see them on hamqsl.com. The sun graphic in the bottom right corner goes from "sad" to "happy" depending on the SFI. You can see right now he's "dead" as the flux is very low.
The basic idea was to get the data from the feed, and just append it to the bottom of the template. ANSI positional codes (in this case, Mystic's MCI codes) are used to move the data to the right place in the template.
The basic idea was to get the data from the feed, and just append it to the bottom of the template. ANSI positional codes (in this case, Mystic's MCI codes) are used to move the data to the right place in the template.
You did a really great job, I wanted to say kudos. Would you mind if I tried to emulate what you did? Or, if your work is open source, would
you mind if tried to rewrite the whole thing from Python into Javascript and credit you with the module?
My post was basically because I was tinkering around to see if I could even play with the data before I started attempting to write anything else.
you can also use ansi positioning codes.
i would first dump the 'art' for the template and at the ass end of the file tack on the position codes with the data.
On 07/28/16, KenDB3 said the following...
You did a really great job, I wanted to say kudos. Would you mind if I tried to emulate what you did? Or, if your work is open source, would you mind if tried to rewrite the whole thing from Python into Javascript and credit you with the module?
Thanks! I'm not a coder or anything and this was the first thing I ever did in Python. It started out just outputting the data like a list, and then I just started adding onto it, making that template for it, etc. I originally wrote it for DayDream BBS, but I re-did it and started using mystic's MCI codes rather than ANSI positioning.
I run the script as a door from the BBS, or it could be a timed event, and it just generates a text file which is then displayed to the user.
The module that does the heavy lifting is xmltodict, which I'm told is very similar to JSON. I use it for some other stuff like a Top 10 Box Office listing, and I had a Summits on the Air spot lister once upon a time also.
You're free to use whatever you like. I was basically just riffing off the solar widgets from hamqsl. I actually sent him a screenshot of it in action and he loved it.
My post was basically because I was tinkering around to see if I could even play with the data before I started attempting to write anything else.
Good luck with it! Let me know if you want to see the Python and I'll try to figure out a way to make it available. I never really released anything because my code is so bad I didn't want to get ridiculed for it, heheh.
In the meantime, I hope this solar flux index goes back up. I can't make any magic happen on the airwaves...
There's already some code for dealing with this exact feed, but it's embedded in an IRC bot. You might be able to find something useful in: '/exec/ircbots/ham/ham.js', however this should work:
load('http.js');
try {
var solardata = new XML(
(new HTTPRequest()).Get(
'http://www.hamqsl.com/solarxml.php'
).replace(
/<\?[^?]*\?>/g, ''
)
).solardata;
} catch (err) {
log('Shit done borked! ' + err);
}
(See https://bbs.electronicchicken.com/temp/solar.txt if that didn't come through okay.)
You should then be able to get at the values from the feed like so:
print(solardata.sunspots);
print(solardata.solarwind);
And so on.
The IRC bot code mentioned above has examples of how to deal with the nested 'calculated(vhf)conditions' values, which gets deeper into E4X than I care to do right now.
I notice in the IRC bot code that you can get banned for hitting the web page too often.
Would there be a way to bring in the XML data without an HTTPRequest from a local file? Say
I notice in the IRC bot code that you can get banned for hitting the web page too often.
Yes, this is something that I recall hearing about in the past. I guess you get x number of hits per day.
Would there be a way to bring in the XML data without an HTTPRequest from a local file? Say
Sure. I would do something like this:
load('http.js');
var url = 'http://www.hamqsl.com/solarxml.php';
var file = system.data_dir + 'solardata.xml';
var age = 43200; // Seconds
// Fetch data via HTTP and write to file specified above
function getSolarData() {
var sd = (new HTTPRequest()).Get(url);
var f = new File(file);
f.open('w');
f.write(sd);
f.close();
}
// Read data from local file and return parsed XML object
function readSolarData() {
var f = new File(file);
f.open('r');
var sd = new XML(f.read().replace(/<\?[^?]*\?>/g, ''));
f.close();
return sd;
}
// Fetch new data if local file timestamp less than file age specified above if (!file_exists(file) || time() - file_utime(file) > 43200) getSolarData();
// Read the current data on hand
var sd = readSolarData();
// Now start printing out that fascinating solar data and your happy/sad sun face
It would be worth throwing in some try ... catch blocks somewhere in there, because the HTTP load or XML parsing portions may fail for a variety of reasons.
You could also move the data-fetching part into a separate script and run it on a schedule once, twice, or however many times per day that you want, then the user facing script just loads whatever data is in the file that the other script writes to.
I faced the same quandary when I was putting together Sports Stats. Ultimately I decided to use Python to write my data scraper. It pulls in the XML and converts it to JSON. Once the data is in JSON, then I can parse it using Sync's JS.
Sysop: | Tandy |
---|---|
Location: | New York, USA |
Users: | 15 |
Nodes: | 13 (0 / 13) |
Uptime: | 03:56:51 |
Calls: | 335 |
Messages: | 112,921 |