Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Getting a source page without loading the page

Hi,


I'd like to get the source of a page without loading it in Safari. I don't need to display the images, ads, etc and it's just to get an URL in the source page by searching it with another function already done.


Is it possible ?


Thx.

Posted on May 23, 2015 12:05 PM

Reply
Question marked as Best reply

Posted on May 23, 2015 12:13 PM

In fact, I had a doubt but I can do that really simply with curl like :

curl www.google.com


Right ?

3 replies

May 23, 2015 5:40 PM in response to Combo

Hello Combo,

In most cases, you are correct. However, there are two important caveats:

1) You may need the "-L" option on curl in case the server redirects you to a new site

2) Many modern, complex sites (such as Apple Support Communities) really aren't self-contained web pages in the same sense as traditional web pages. When you download the "source", you are just downloading a basic architecture and links to embedded scripts. Then the web browser would download and run those scripts. The scripts would then talk to the server and actually build the web page you see in the browser. In this case, the only option would be to use Safari's Develop menu and look at the DOM (Document Object Model) of the site as it has been constructed in Javascript. It may not bear much resemblance to the original source you would get from curl.

Getting a source page without loading the page

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.