How do I get a page's HTML?

Get help using Construct 2

Post » Mon Jul 17, 2017 3:33 pm

Hi, I want to get a webpage's HTML.

I tried with AJAX Request URL (webpage's URL) and then get the page's HTML from AJAX.LastData. My problem is it does not always work, for example, it does work with
Code: Select all
AJAX Request: "http://www.nationalgeographic.com/"
but it does not work with
Code: Select all
AJAX Request: "http://www.scirra.com/"
Anyone got a clue?
B
20
S
6
Posts: 143
Reputation: 1,666

Post » Tue Jul 18, 2017 7:26 am

ChesVCF wrote:Hi, I want to get a webpage's HTML.

I tried with AJAX Request URL (webpage's URL) and then get the page's HTML from AJAX.LastData. My problem is it does not always work, for example, it does work with
Code: Select all
AJAX Request: "http://www.nationalgeographic.com/"
but it does not work with
Code: Select all
AJAX Request: "http://www.scirra.com/"
Anyone got a clue?

It's because that's what they've set on their servers.
"No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'yourIP:50000' is therefore not allowed access."

If you set "Preview browser" to "NW.js", it will work because it will run as an app locally. Similar story will be present when exporting – I'm pretty sure if you export to HTML5 and upload to your server, it won't work. However, NW.js and Androdid export should work.

When previewing in Chrome, there is one trick you could try – disabling this warning. Make sure only to use this when testing, not when browsing normally, because it could potentially be dangerous.
If you open cmd at the install directory of Chrome and type in the following code, Chrome will open with the warning disabled:
Code: Select all
chrome.exe --disable-web-security --user-data-dir

(make sure you close all Chrome instances before that)

After you're done with testing, closing all Chrome instances will revert Chrome back to normal mode.
B
32
S
7
G
4
Posts: 398
Reputation: 4,591

Post » Tue Jul 18, 2017 8:35 am

@ChesVCF I tried this awhile ago aswell this could be quite a cool tool to use.
Image
B
24
S
13
G
11
Posts: 277
Reputation: 8,685

Post » Tue Jul 18, 2017 10:31 am

@grigrizljac
Wow that was extremely helpful. Thank you for your reply :) I have no problem with it as I want to export to Android, but I will try with NW.js or disabling this warning in Chrome while I am previewing my app.
B
20
S
6
Posts: 143
Reputation: 1,666


Return to How do I....?

Who is online

Users browsing this forum: AndreasR and 12 guests