I'm trying to make my own DB with data pulled from a Javascript Variable located on this URL (https://www.numberfire.com/nba/fantasy/fantasy-basketball-projections/). Since the data is only made available in the variable (NF_DATA), I'm not able to easily query as I would an API.
I'm able to pull the data as I would any JSON object using the Chrome Developer Console as such:
I would like to be able to pull data with a Python script in the same way as I was doing in the Chrome Developer Console. (For instance, identifying the exact data by writing 'NF_DATA['daily_projections']['1'][...]' in the script, so I can do the manipulation directly in the script, not in Chrome Devtools). Any recommendations on how I do this? I have tried using BeautifulSoup in Python, but was having trouble grabbing the data without making the complete output into a string (would this even be a good way to think about it??)
Related
When I inspect a webpage I can see javascript files with name and a query string attached to their name. Like: jquery-1.9.1.min.js?ctag=0$$16.0.4230.1217.
I googles ctag but didn't find anything useful which I can understand.
I want to know what is the difference between files with ctag and without it?
(jquery-1.9.1.min.js vs. jquery-1.9.1.min.js?ctag=0$$16.0.4230.1217)
When you see http parameters added to the end of a script url it's usually for one of two reasons.
To cache the script in the browser.
Usually a version number is added, the cache can then be forced to update by changing the version. i.e.
http://example.com/js/myscrpt.js?ver=0.4
To send data to the server.
It might be that the script being returned is actually generated server side and the parameter is sending a value that is used in the generation of that script. i.e.
http://example.com/js/myscript.js?userid=935284025805
UPDATE: searching the web, it seems that links deployed on Sharepoint using JSLINK adds a ctag parameter to the urls of javascript files. It's possible the link is from a Sharepoint site, see here and here for Sharepoint questions about the added ctag
I'm very new to JavaScript, and much more of an analyst than a programmer.
You know how you can open up Chrome's Console and type in a JavaScript variable, and the value of that variable will be returned? I want to know if it's possible to grab those variables from within Google Drive/Docs or Google Apps Script.
I've seen a few examples on StackOverflow of getting the values of certain XML elements (say, the text within a title tag), but I don't want to grab the entire contents of the script that contains these variables (as would be returned with an XPath query), just the variables themselves.
Is this possible?
You can exchage data between your web screen and you server side apps script by using the call
google.script.run.yourServerSideFunction(your parameters).
You can see more about server and client communications here.
I'm building a game using HTML5 Canvas and Javascript and I'm using JSON formatted tile maps for my levels. The tiles render correctly in FireFox, but when I use Chrome, the JSON fetching fails with a "Origin null is not allowed by Access-Control-Allow-Origin." I was using jQuery's $.ajax command and all my files are in one directory.
I would use this post's solution, but I can't use the web server solution.
Is there any other way to fetch JSON files to be parsed and read from? Something akin to loading an image just by giving the URL? Or is there some way to quickly convert my JSON files into globally available strings so I can parse it with JSON.parse()?
Why is the local web server not an option? Apache is free, can be installed on anything, and easy to use, IMO. Also, for Chrome specifically, look into --allow-file-access-from-files
But if nothing else works, maybe you could just add links to the files in script tags, and then append var SomeGlobalObject = ... to the top of each file. You might even be able to do this dynamically by using JS to append the script tag to head. But in the end, instead of using AJAX, you can just do JSON.parse(SomeGlobalObject)
In other words, load the files into the global namespace by adding script tags. Normally this would be considered bad practice, but used ONLY for testing, in the absence of any other options, it may work.
One option which may work for you in Chrome is to invoke the browser with the command line switch --allow-file-access-from-files. This question addresses the issue : Google Chrome --allow-file-access-from-files disabled for Chrome Beta 8
Another possibility is to fetch the JSON data as a script, setting a global variable to the JSON value
I've searched around the internet for a couple of hours and could not find anything related to what I'm trying to do. I wrote a HTML document that collects data from a user and stores it in a javascript array. This array is then joined together and stored as a string in a document which is hidden. Originally, I was going to transfer this string to a program I wrote in C#, but now I am using LabVIEW.
In C#, I used two simple lines of code to do what I wanted:
System.Windows.Forms.HtmlElement hidden = webBrowser1.Document.GetElementById("hiddenfield1");
List<latlng> data = formharvest.extract(hidden.GetAttribute("value"));
But now I cannot find a way to access the data that is in this hidden document. I'm using the IWebBrowser2 block to embed my HTML code in my VI. Any help would be greatly appreciated. Thank you for your time!
A solution would be to start a Web server in your LabVIEW program, and serve your HTML form from it. I suppose it wouldn't be too hard to retrieve form data then, but I haven't done such thing myself.
Here's an interesting discussion on this with sample code.
I'm not sure I really understand what you are doing above: in the C#, it looks like you are embedding an HTML-rendering engine in a Windows form (i.e. window).
You can embed .NET in your labview code and therefore you should be able to embed the same HTML rendering engine in a LabView VI, but you might consider changing your approach, as CharlesB suggests, to something more traditional where a server serves some HTML to a web browser, which then sends some data back to the server via HTTP GET or POST.
I have created an application, where I need to get error logs (if any) when web services fail. I'm planning to go ahead using ExternalInterface in Flex and using JavaScript. Does anyone have any experience with this?
You can log errors though the javascript console (viewable in Firebug, for example) with the following line of code:
ExternalInterface.call("console.log","Error: Error message goes here");
What do you plan to do once you pass data from Flash to JavaScript? Were you expecting JavaScript to create data in local files? Is that even possible?
I would recommend looking at Flash Shared Objects to store limited data locally. They are kind of like the Flash version of browser cookies. If you're using AIR then just create a local File and dump your relevant data in it.