1
  1. I use wget to save a webpage to a file 'annie.html'.
% wget -qO-  http://www.swagbucks.com/watch/video/523803/annie > annie.html
  1. Inside this file is this line:
<div id="sbPlaylistVideoContainer" class="fullSize"></div>
  1. Question is: How do I get the actual code for this <div> element? If I right-click on the video in Chrome for this and click "Inspect element", I see the actual code.

It looks like this.

<video id="example_video_1_html5_api" class="vjs-tech" preload="none" src="blob:http%3A//www.swagbucks.com/096df37a-81fe-4c65-b082-0fe059254d6e" style=""><source src="http://progressive.totaleclips.com.edgesuite.net/137/e137013_257.mp4?eclipid=e137013&amp;bitrateid=457&amp;vendorid=1839&amp;type=.mp4" type="video/mp4"></video>

Where did Chrome get this from? It does not exist in the webpage. I would like to get the proper 'wget' command syntax that will save this code to a file.

2 Answers 2

2

Without actually analyzing the webpage, its impossible to say for sure, however it is most likely that the website is using JavaScript to inject the video player into the page. The Chrome "Inspect element" feature shows the DOM's current state, not necessarily the the true source for the page.

There are several reasons a website would do this including the detect the capabilities of your browser in order to render an appropriate player (ie HTML video or a Flash player) or to have the capability to dynamically change the video.

1
  • You've basically written what I wanted to post as an answer, except yours is more understandable. +1 from me for that reason. :)
    – LPChip
    Mar 31, 2016 at 14:42
0

The webpage is dynamically generated. Because you view the webpage with Chrome, which is HTML5 capable, the server gives you the tag which is a html5 tag. wget does not identifies itself as chrome, and so the server defaults to a backwards compatible

Both commands are valid though.

2
  • If I right-click and choose "View page source" in Chrome, I see the exact same thing as wget. I also set wget --user-agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36" which is what Chrome sends and it saves the same file as before.
    – chiwal
    Mar 31, 2016 at 13:35
  • If I inspect the element, it shows me the same source as the View Page Source, but the page auto loads to the next. Maybe you're comparing 2 different sites?
    – LPChip
    Mar 31, 2016 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .