<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cookie Consent issue in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457609#M70266</link>
    <description>&lt;P&gt;Are you trying to open the page in JMP or scrape the website? If you are trying to scrape (I'm not too familiar with web scraping), but you can try something like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/57171353/scraping-a-webpage-using-python-beautiful-soup-that-requires-i-agree-to-cooki" target="_blank"&gt;https://stackoverflow.com/questions/57171353/scraping-a-webpage-using-python-beautiful-soup-that-requires-i-agree-to-cooki&lt;/A&gt; then in JMP use New HTTP Request with fields or possibly Cookie (check scripting index for these).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could even be that GET request with New HTTP Request() is enough without any extra fields&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);&lt;BR /&gt;
request = New HTTP Request(
	URL("https://www.jmp.com/en_us/home.html"),
	Method("Get")
);
data = request &amp;lt;&amp;lt; Send;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 01 Feb 2022 18:49:08 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2022-02-01T18:49:08Z</dc:date>
    <item>
      <title>Cookie Consent issue</title>
      <link>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457106#M70230</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;when attempting to open the html code of a webpage i only get the Cookie Consent text rather than the page content.&lt;/P&gt;
&lt;P&gt;For example, being in the UK and attempting to open the jmp homepage this is what i get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
//:*/
Page = open("https://www.jmp.com/");

/*:

String( "&amp;lt;html&amp;gt;&amp;lt;hea... 2588 total characters ...&amp;gt;&amp;lt;/html&amp;gt;

" ) assigned.

//:*/
print (Page);
/*:

"&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;script type=\!"text/javascript\!"&amp;gt;
function callAjax(url, fallbackUrl, callback){
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState === 4 &amp;amp;&amp;amp; xmlhttp.status === 200){
            callback(xmlhttp.responseText);
        }
    }
    xmlhttp.open(\!"GET\!", url, true);
    xmlhttp.timeout = 3000; // time in milliseconds
    xmlhttp.ontimeout = function() {
        console.log(\!"countrycode xhr request timed out\!");
        window.location.replace(fallbackUrl);
    }
    xmlhttp.send();
}

function findInLocales(locales, cookielocale) {
    var i = 0;
    var found = \!"\!";
    while (i &amp;lt; locales.length &amp;amp;&amp;amp; !found) {
        if (locales[i].substring(2) === '_' + cookielocale.toLowerCase()) {
            found = locales[i];
        }
        i++;
    }
    return found;
}

function geoResetURL(locales) {
    var windowReplacement = window.location.href;
    var regex = /\/[a-zA-Z][a-zA-Z]_[a-zA-Z][a-zA-Z]\//;
    var regextest =  /[a-zA-Z][a-zA-Z]_[a-zA-Z][a-zA-Z]/;
    windowReplacement = windowReplacement.replace('.geo.', '.');
    var match = document.cookie.match(new RegExp('(^| )usr_locale=([^;]+)'));
    var cookielocale = '';
    if (match != null &amp;amp;&amp;amp; match.length &amp;gt; 2) {cookielocale = match[2];}
    if (!cookielocale.match(regextest)) {
        var result;
        var code = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
        callAjax( '/services/countrycode?'+code, windowReplacement,
                function (result) {
                    var jsonresult = result.replace(/[()]/g, '');
                    cookielocale = findInLocales(locales, (JSON.parse(jsonresult)).address.country_code);
                    if (locales.indexOf(cookielocale) != -1) {
                        windowReplacement = windowReplacement.replace(regex, '/' + cookielocale + '/');
                    }
                  window.location.replace(windowReplacement);
                });
    } else {
        if (locales.indexOf(cookielocale) != -1) {
            windowReplacement = windowReplacement.replace(regex, '/' + cookielocale + '/'); 
        }
        window.location.replace(windowReplacement);
    }
}

(function () { 
var locales = ['en_us','en_be','de_at','zh_cn','en_dk','fr_fr','de_de','it_it','ja_jp','ko_kr','en_nl','en_ch','en_gb','en_ca','fr_ca','zh_tw','pt_br','es_mx','es_es','en_au','en_hk','en_my','en_ph','en_in','en_sg','es_ar','es_cl','es_co','es_pe']; 
geoResetURL(locales); 
  }) ();&amp;lt;/script&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;
&amp;lt;p&amp;gt;Redirecting ...&amp;lt;/p&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;

"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks for any suggestions in the right direction.&lt;/P&gt;
&lt;P&gt;ron&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:09:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457106#M70230</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2023-06-09T18:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Cookie Consent issue</title>
      <link>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457115#M70231</link>
      <description>&lt;P&gt;Open Developer Tools in your browser (F12), select Network tab and go to jmp.com. From there take a look at the domains / files and try to find "correct one":&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1643556661155.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39595i6504CB6DA56355AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1643556661155.png" alt="jthi_0-1643556661155.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1643556692355.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39596iB4E4F80AA6535EB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1643556692355.png" alt="jthi_1-1643556692355.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now try opening that one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This approach might work or at least get you closer, depending on the website and what you want to get from there.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 15:32:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457115#M70231</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-01-30T15:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cookie Consent issue</title>
      <link>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457210#M70240</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I had a look in the developer tools but didn't manage to crack it yet as a command.&lt;/P&gt;
&lt;P&gt;i managed to get the html of &lt;A href="http://jmp.com" target="_blank"&gt;http://jmp.com/&lt;/A&gt; by performing the following steps:&lt;/P&gt;
&lt;P&gt;1) file&amp;gt;&amp;gt; internet open &amp;gt;&amp;gt; webpage.&lt;/P&gt;
&lt;P&gt;2) open jmp.com as a webpage&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ron_horne_0-1643637187111.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39610iE61D2FB45EE263FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ron_horne_0-1643637187111.png" alt="ron_horne_0-1643637187111.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;3) accept / not accept the cookies interactively&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ron_horne_1-1643637303759.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39611i793D746868A47BE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ron_horne_1-1643637303759.png" alt="ron_horne_1-1643637303759.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;4) run the following statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;page = open ("https://www.jmp.com/en_gb/home.html")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;notes: cookie approval only lasts within the same jmp session. After that preferences are not remembered.&lt;/P&gt;
&lt;P&gt;This method is useful in my case since only fetch information from one domain in each session. therefore, approving manually is not too difficult. if the scrip crosses domains while fetching data it would be nice to somehow automate this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this method also worked for the webpage i was actually fetching data from so it is reliable to that extent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 14:05:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457210#M70240</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2022-01-31T14:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Cookie Consent issue</title>
      <link>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457609#M70266</link>
      <description>&lt;P&gt;Are you trying to open the page in JMP or scrape the website? If you are trying to scrape (I'm not too familiar with web scraping), but you can try something like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/57171353/scraping-a-webpage-using-python-beautiful-soup-that-requires-i-agree-to-cooki" target="_blank"&gt;https://stackoverflow.com/questions/57171353/scraping-a-webpage-using-python-beautiful-soup-that-requires-i-agree-to-cooki&lt;/A&gt; then in JMP use New HTTP Request with fields or possibly Cookie (check scripting index for these).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could even be that GET request with New HTTP Request() is enough without any extra fields&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);&lt;BR /&gt;
request = New HTTP Request(
	URL("https://www.jmp.com/en_us/home.html"),
	Method("Get")
);
data = request &amp;lt;&amp;lt; Send;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Feb 2022 18:49:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457609#M70266</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-02-01T18:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cookie Consent issue</title>
      <link>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457632#M70268</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;, this works perfectly.&lt;/P&gt;
&lt;P&gt;At this point i do want to scrape the page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 19:14:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cookie-Consent-issue/m-p/457632#M70268</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2022-02-01T19:14:12Z</dc:date>
    </item>
  </channel>
</rss>

