.NET Framework Bookmark and Share   
 index > Network Class Library (System.Net) > Download all swf files from web page
 

Download all swf files from web page

Hi!

I am working on a task in which I have to download all flash objects swf and flv files running in web page. I have got no clue to find he source of .swf file, as mostly swf files comes from other servers. I want to find out somw way to find the source / url of .swf currently running. Kindly suggest me some way.

I have 2 ideas in mind, but currently unsuccessful in implementing them

1. Using WebBrowser class and somehow find url of swf.
2. Using Pcap to fetch all http packets and after decoding, some how try to find url coming.

Any other option or some simple way to implement above option would be highly appretiated.

Best Regards

Kaka
KakaSipahe

Hi Kaka,

Using WebRequest to get the html page source and then parsing the source for specific terms you should be able to find the urls of swfs. Take a look at the code sample below:

using

System;

using

System.Net;

using

System.IO;

namespace

ParseHtmlSource

{

class Program

{

static void Main(string[] args)

{

string url = "http://www.adobe.com/";

HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);

myWebRequest.Method =

"GET";

// request to url

HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse();

StreamReader myWebSource = new StreamReader(myWebResponse.GetResponseStream());

string htmlSource = myWebSource.ReadToEnd();

int swfIndex = 0;

//parse html source for .swf

while (swfIndex != htmlSource.Length &&

-1 != (swfIndex = htmlSource.IndexOf(

".swf\"",swfIndex+1)))

{

int beginIndex = htmlSource.LastIndexOf('"', swfIndex);;

int endIndex = htmlSource.IndexOf('"', swfIndex);

Console.WriteLine(htmlSource.Substring(beginIndex,endIndex-beginIndex+1));

}

swfIndex = 0;

while (swfIndex != htmlSource.Length &&

-1 != (swfIndex = htmlSource.IndexOf(

".swf'", swfIndex + 1)))

{

int endIndex = htmlSource.IndexOf("'", swfIndex);

int beginIndex = htmlSource.LastIndexOf("'", swfIndex);

Console.WriteLine(htmlSource.Substring(beginIndex, endIndex - beginIndex + 1));

}

myWebResponse.Close();

}

}

}

Jovana Florus

You can use google to search for other answers

Custom Search

More Threads

• Reusing TCP connection when using HTTPWebRequest
• UDPClient usage and security sanity check
• Append header with internal Request, Response
• Implementing file uploads using FTPS over SSL
• Multiple UDP connections - 1 PC
• Questions about TcpClient / TcpListener and Socket classes
• About Webclient
• Sending signed and encrypted S/MIME (PKCS 7) mail with .net
• Does ServerCertificateValidationCallback apply globally to an application?
• mini project