How to extract only links finished by extensions .swf ?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
hackoo
Posts: 103
Joined: Fri Jan 21, 2011 11:27 pm

How to extract only links finished by extensions .swf ?

Post by hackoo »

Hi ;)
I wonder how to extract only links finished by extensions .swf from the source code of a web page and save them on text file in order to download them after ?
So i just have this code :
PowerShell Code
Double-click the code block to select all.
$ie = new-object -ComObject InternetExplorer.Application
$ie.Navigate2('http://www.addictinggames.com/car-games/moto-x3m-game.jsp')
while($ie.Busy){}
$ie.Document.links|select href

User avatar
SAPIEN Support Forums
Posts: 945
Joined: Wed Dec 03, 2014 1:26 pm

How to extract only links finished by extensions .swf ?

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, hackoo.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum: If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
  • 1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***

jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: How to extract only links finished by extensions .swf ?

Post by jvierra »

We would use this to parse a page:
PowerShell Code
Double-click the code block to select all.
$doc=Invoke-WebRequest http://www.addictinggames.com/car-games/moto-x3m-game.jsp
$doc.links|?{$_.href -match '\.jsp'}|select href
I used .jsp because that page has no SWF links on it.

User avatar
hackoo
Posts: 103
Joined: Fri Jan 21, 2011 11:27 pm

Re: How to extract only links finished by extensions .swf ?

Post by hackoo »

Thank you for your reply but i don't know why i got this error
Le terme « Invoke-WebRequest » n'est pas reconnu comme nom d'applet de commande, fonctio
n, fichier de script ou programme exécutable. Vérifiez l'orthographe du nom, ou si un ch
emin d'accès existe, vérifiez que le chemin d'accès est correct et réessayez.
Au niveau de ligne : 2 Caractère : 23
+ $doc=Invoke-WebRequest <<<< http://www.addictinggames.com/car-games/moto-x3m-game.jsp
+ CategoryInfo : ObjectNotFound: (Invoke-WebRequest:String) [], CommandNot
FoundException
+ FullyQualifiedErrorId : CommandNotFoundException

jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: How to extract only links finished by extensions .swf ?

Post by jvierra »

You need PowerShell V3 (WMF3) or later to use that.

jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: How to extract only links finished by extensions .swf ?

Post by jvierra »

PowerShell Code
Double-click the code block to select all.
$ie = new-object -ComObject InternetExplorer.Application
$ie.Navigate2('http://www.addictinggames.com/car-games/moto-x3m-game.jsp')
while($ie.Busy){}
$ie.Document.links|select -expand href |?{$_ -match '\.jsp'}

User avatar
hackoo
Posts: 103
Joined: Fri Jan 21, 2011 11:27 pm

Re: How to extract only links finished by extensions .swf ?

Post by hackoo »

When i do like this i got nothing because,i think what i want to catch is http://www.addictinggames.com/newGames/ ... to-x3m.swf and is located under a javascript not a link ? so is there a workaround to do that correctly ?

Code: Select all

<script type="text/javascript">
	document.addEventListener('DOMContentLoaded', function(){

		ag.gameData = {
			keyword: 'moto-x3m',
			title: 'Moto X3M',
			thumbNail: 'http://www.addictinggames.com/newGames/car-games/moto-x3m/moto-x3m.png',
			description: 'Do crazy tricks on some very goofy dirtbike tracks!',
			URL: 'http://www.addictinggames.com/car-games/moto-x3m-game.jsp',
			isHighScore: false,
			
					isServiceManagerEnabled: false
		};

		com.mtvnet.games.GameSettings.Ad.timePerAd = 0; //Time in seconds from game load to play an Ad. 0 is default.
		com.mtvnet.games.GameSettings.Ad.width = 800; //640 is default
		com.mtvnet.games.GameSettings.Ad.height = 600; //480 is default
		com.mtvnet.games.GameSettings.Ad.timeDisplayEnabled = true; //true is default
		//	com.mtvnet.games.GameSettings.Ad.language = 'fr'; //en is default.
		com.mtvnet.games.GameSettings.Ad.Quantcast.enabled = true; //true is default. Enable demographic targetting
		com.mtvnet.games.GameSettings.Ad.DoubleClick.enabled = false;//true is default
		com.mtvnet.games.GameSettings.Ad.DoubleClick.keyValues = 'gen=game;!category=expand;!category=pop;!category=float;'+ag.getTestMode; //"" is Default

		// true
				ag.showVideoAd = ag.shouldShowVideoAd( 1 ); // controls ad play based on ratio
				com.mtvnet.games.GameSettings.Ad.gamePerAd = 0; //0 is default. Always play an ad. Override with disableAds property.
				
						com.mtvnet.games.GameSettings.Ad.disableAds = ( ag.showVideoAd ) ? false : true; // inverting our boolean return to match
						com.mtvnet.games.GameSettings.Ad.FreeWheel.enabled = true; //false is default
					

		com.mtvnet.games.GameSettings.Ad.FreeWheel.networkId = 82125; //82125 is default
		com.mtvnet.games.GameSettings.Ad.FreeWheel.siteSection = 'addictinggames__games'; //MTVN_Viral_Syndication is default
		com.mtvnet.games.GameSettings.Ad.FreeWheel.assetId = 'moto-x3m'; //all_temporal_test_asset is default
		com.mtvnet.games.GameSettings.Ad.FreeWheel.isLiveEnvironment = true; //true is default which points to live FW environemnt

		com.mtvnet.games.GameSettings.Game.height = 600; //480 is default
		com.mtvnet.games.GameSettings.Game.width = 800; //640 is default

	    com.mtvnet.games.GameSettings.Game.metadata.gameURL = 'http://www.addictinggames.com/newGames/car-games/moto-x3m/moto-x3m.swf?c=111';
	    com.mtvnet.games.GameSettings.Game.metadata.preview = "";
	    com.mtvnet.games.GameSettings.Game.gameEmbedTag = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" id="gameObject" width="800" height="600"><param name="movie" value="http://www.addictinggames.com/newGames/car-games/moto-x3m/moto-x3m.swf"/><param name="menu" value="false"/><param name="allowscriptaccess" value="samedomain"/><param name="allownetworking" value="all"/><embed src="http://www.addictinggames.com/newGames/car-games/moto-x3m/moto-x3m.swf" width="800" height="600" menu="false" allowscriptaccess="always" allownetworking="all" name="gameObject" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';

		com.mtvnet.games.GameSettings.Game.metadata.gameTitle = "Moto X3M"; //NA is default
		com.mtvnet.games.GameSettings.Game.metadata.gameId = "moto-x3m"; //NA is default
	//	com.mtvnet.games.GameSettings.Game.metadata.franchise = "[Franchise]"; //"" is default
	//	com.mtvnet.games.GameSettings.Game.metadata.partner = "aol"; //"" is default
		com.mtvnet.games.GameSettings.Game.metadata.gameGenre = "Car"; //NA is default
		com.mtvnet.games.GameSettings.Game.metadata.gameType = "Car"; //"" is default
		com.mtvnet.games.GameSettings.Game.metadata.gameName = "Moto X3M"; //"" is default
		com.mtvnet.games.GameSettings.Game.metadata.type = "network"; //network is default
		com.mtvnet.games.GameSettings.Game.metadata.ref = "www.addictinggames.com"; //location.href is default
		com.mtvnet.games.GameSettings.Game.metadata.orig = "www.addictinggames.com";//NA is default
		com.mtvnet.games.GameSettings.Game.metadata.ageGroup = "ALL AGES"; //"" is default. "mature" for mature games
	//	com.mtvnet.games.GameSettings.Game.metadata.revenueSplit = true; //"" is default

	//	com.mtvnet.games.GameSettings.Reporting.Omniture.enabled = true; //true is default

		var stub = com.mtvnet.games.GameSettings.Game;

		// pass any querystring parameters attached to the page along to the src attribute of an iframed game
		if ( stub.gameEmbedTag.indexOf( 'iframe' ) !== -1 ) {
			if ( window.location.search !== '' ) {
				var qs = btg.String.queryStringToObject( window.location.search );
				var re = /src\s*=\s*[\""\']?([^\""\'\s>]*)/;

				var infoArray = re.exec( stub.gameEmbedTag );
				var newSrcString = 'src="' + infoArray[1];

				if ( newSrcString.indexOf( '?' ) !== -1 ) { // game already has a querystring
					for ( var val in qs ) {
						newSrcString = newSrcString + '&' + val + '=' + qs[val];
					}
				} else { // no querystring in embed url
					newSrcString = newSrcString + '?';
					var count = 0;
					for ( var val in qs ) {
						if ( count > 0 ) {
							newSrcString = newSrcString + '&';
						}
						newSrcString = newSrcString + val + '=' + qs[val];
						count++;
					}
				}

				newSrcString = newSrcString + '"';
				stub.gameEmbedTag = stub.gameEmbedTag.replace( re, newSrcString );
			}
		}

		com.mtvnet.games.GameLoader.init(document.getElementById("gameContainer"));
		
	});
</script>

jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: How to extract only links finished by extensions .swf ?

Post by jvierra »

No there is no "work-around" if the link is on another page or is synthetic then you cannot get it. Many web designers do this to prevent what you are doing. Others do it so the links can be changed in a database without having to change the page. ASP.Net pages are also like this. You cannot predict any instance of a page.

I am not saying it Is impossible but that you have to figure it out on a case by case basis. That is why they pay big bucks to people who know how to do this. I cannot teach you how to do it. It comes from knowing and having experience with web coding and design as well as many hours of screen scraping. It is mostly an art backed by a broad skillset. It cannot be taught in an afternoon.

Locked