1

I've been trying to implement some HTML code that accesses weather data in historical CSV files online, and perform maths on the data once I selectively extract it.

In the past, I've programmed in Python and had no problems doing this by using pycurl.Curl(). HTML is a complete nightmare in comparison: XMLHttpRequest() does technically work, but web browsers automatically block access to all foreign URLs (because of the Same-Origin Policy). Not good.

Any ideas and alternative approaches would be very helpful!

A.D.
  • 2,352
  • 2
  • 15
  • 25
poopipeboy
  • 11
  • 1
  • The same origin policy exists for a reason - I can assure you that, although it's a pain, it's in fact quite good when you consider the shenanigans it prevents. – Shadow Jan 10 '18 at 04:55
  • True. I might go back to investigating how to upload files into the same location as the HTML code. Easier said than done when you're using GoDaddy, with their lack of documentation. – poopipeboy Jan 10 '18 at 05:10
  • GoDaddy supports php, right? Maybe have a look at https://stackoverflow.com/questions/4645082/get-absolute-path-of-current-script to work out where you need to dump said files. Not sure if you get write access from scripts though... – Shadow Jan 10 '18 at 05:13

2 Answers2

0

I would look into YQL for this.

https://developer.yahoo.com/yql/

Nice Gist as example querying a CSV file. https://gist.github.com/RandomEtc/491827

Best of luck!

iamjpg
  • 7,078
  • 1
  • 16
  • 18
  • I'll give it a go, looks like it might be what I need. – poopipeboy Jan 10 '18 at 03:38
  • Looks like it might've worked at some stage, but from what I gather, YQL has been discontinued as of mid-2017. And it makes sense because the YQL examples on their main website don't seem to work anymore. – poopipeboy Jan 10 '18 at 05:20
0

I'm pushing against the boundaries set forth in your question.. if you're simply wanting to do it in JavaScript, but outside the context of a browser, have you considered working in Node?

bkwdesign
  • 1,953
  • 2
  • 28
  • 50
  • I'd like to work outside of browsers, but my goal is to put this tool on a website for user access, so unfortunately I'm stuck with HTML. But I didn't realise it would be so hard to simply access remote data files.... – poopipeboy Jan 10 '18 at 04:14
  • You could do your cURL work on the server, and have the HTML access it from your server, in a same-origin manner – bkwdesign Jan 10 '18 at 04:16