Yahoo Finance HTMLs contain JSON data in the middle as follows (I somewhat truncated the HTML to show how it looks): <!DOCTYPE html><html id="atomic" class="NoJs desktop" lang="en-US"><head prefix="og: http://ogp.me/ns#"><script>window.performance && window
</script><script>!function(e,s,f,p){var a=[],t={_version:"3.11.4",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},
if (!window.YAHOO || !window.YAHOO.i13n || !window.YAHOO.i13n.Rapid) { return; }
var rapidConfig = {"async_all_clicks":true,"click_timeout":300,"client_only":1,"compr_type":"deflate","keys":{"ver":"ydotcom","navtype":"ser
window.rapidInstance = new window.YAHOO.i13n.Rapid(rapidConfig);
})();</script></head><body><div id="app"><div class="" data-reactroot="" data-reactid="1" data-react-checksum="1106760844"><div data-reactid
window._adPerfData = [];
window._adPosMsg = [];
window._perfMark = function _perfMark (name) {if (window.performance && window.performance.mark){try {if (window.performance.getEntriesByNam
window._perfMeasure = function _perfMeasure (name, start, end) {if (window.performance && window.performance.measure){try {if (window.perfor
window._pushAdPerfMetric = function _pushAdPerfMetric(key) {if (window.performance && window.performance.now) {_adPerfData.push([key, Math.r
window._fireAdPerfBeacon = function _fireAdPerfBeacon(eventName) {try {if (window && window.rapidInstance && window.performance) {var navCli
window.rapidInstance.beaconPerformanceData(perfData);}} catch (e) {console.warn('Could not send the beacon:',e);}};
window.DARLA_CONFIG = {"debug":false,"dm":1,"autoRotation":10000,"rotationTimingDisabled":true,"k2":{"res":{"rate":5,"pos":["BTN","BTN-1","B
window.DARLA_CONFIG.servicePath = window.location.protocol + "//fc.yahoo.com/sdarla/php/fc.php";window.DARLA_CONFIG.dm = 1;window.DARLA_CONF
window.DARLA_CONFIG.onFinishRequest = function() {window._perfMark('DARLA_REQEND');};
window.DARLA_CONFIG.onStartParse = function() {window._perfMark('DARLA_PSTART');};
window.DARLA_CONFIG.onSuccess = function(eventName) {if (eventName === 'AUTO') {return;}if (window._DarlaEvents) {window._DarlaEvents.emit("
window.DARLA_CONFIG.onStartPosRender = function(posItem) {var posId = posItem && posItem.pos;window._perfMark('DARLA_ADSTART_' + posId);if (
window.DARLA_CONFIG.onFinishPosRender = function(posId, reqList, posItem) {var ltime;window._perfMark('DARLA_ADEND_' + posId);window._perfMe
window.DARLA_CONFIG.onBeforePosMsg = function(msg, posId) {var maxWidth = 970, maxHeight = 600;var newWidth, newHeight, pos;if (window._Darl
window.DARLA_CONFIG.onFinishParse = function(eventName, response) {try {if (eventName !== "AUTO") {var positionlist = response.ps();var foun
};
window.DARLA_CONFIG.onStartPrefetchRequest = function(eventName) {window._perfMark('DARLA_PFSTART');};
window.DARLA_CONFIG.onFinishPrefetchRequest = function(eventName, status) {window._perfMark('DARLA_PFEND');try {window._DarlaEvents.emit('fi
};
window.DARLA_CONFIG.onPosMsg = function(cmd, pos, msg) {try {if (window._DarlaEvents && cmd === "cmsg") {var posmsg = {pos: pos,msg: msg};wi
};
(function () {var _onloadEvt = function _onloadEvtHandler() {window._loadEvt = true;if (window._darlaSuccessEvt) {window._fireAdPerfBeacon(w
window.$sf = window.sf = {};
window.$sf.host = {onReady: function (autorender, deferrender, firstRenderPos, deferRenderDelay) {window._perfMark('DARLA_ONREADY');window._
};
window.sf_host = window.$sf.host;
document.onreadystatechange = function () {if (document.readyState == "interactive") {window._perfMark('DOM_INTERACTIVE');}};</script>
<script type="text/x-safeframe" id="fc" _ver="4-9-0">{"positions":[{"id":"FB2A","html":"<!-- SpaceID=0 robot -->\n","lowHTML":"","meta":{"y"
<!-- bf1-sdarlaws-046.adx.bf1.yahoo.com Sat Sep 18 16:26:34 UTC 2021 -->
<script type="text/javascript">if (typeof DARLA !== "undefined" && DARLA) {DARLA.config(window.DARLA_CONFIG);window.sf_host.onReady(true,tru
<style>
.hide-lrec-ad .darla-lrec-ad {display: none;}.hide-non-lrec34 .darla-nonlrec34-ad {display: none;}.hide-non-lrec34 .sticky-outer-wrapper .td
</div><script>
(function (root) {
/* -- Data -- */
root.App || (root.App = {});
root.App.now = 1631982394842;
root.App.main = {"context":{"dispatcher":{"stores":{"PageStore":{"currentPageName":"quote","currentEvent":{"eventName":"NEW_PAGE_SUCCESS"},"
}(this));
</script><script>
(function(win) {
win.vzm = win.vzm || {}; The sixth line from the bottom above contains a JSON value root.App.main. I wanted to isolate these JSON data, create a new JSON file WANT.json as follows (a trouble occurred at this point), and then read the created JSON using libname JSON. filename HAVE temp;
proc http url="https://finance.yahoo.com/quote/KO/financials?p=KO" out=HAVE;
run;
data _null_;
infile HAVE;
input;
file "/home/junyong0/WANT.json";
if _infile_=:"root.App.main" then put _infile_;
run; The problem is the 32,767 LRECL limit applied to _INFILE_. The resultant WANT.json contains only the first 32,767 letters truncating all the remainders. Is there any way to handle this long line to get an appropriate JSON file? Or I wonder if there is a simpler way to read HTML-embedded JSON.
... View more