473,382 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Capturing the output of a script src tag

I'm sure you all have seen how using the src argument in a script tag
is essentially the same as including the body of the script within
your page. For example:

<script type="text/javascript"
src="http://somepage.com/somead/show_ads.js">
</script>

Is there a way to capture the html output of that script and save it
to a variable or text file so that I can use a language like php to
parse it and look for certain words or phrases?

For instance, this particular url executes some javascript code which
produces an iframe on my page, but view source only displays the
script tag. Using innerHTML I can get the iframe code to print in
another browser window, but I would prefer the iframe html be save to
a variable or text file so that I can write a script to parse it on
the fly.

Please let me know if I'm being unclear and I'll try rephrasing my
problem.

Thanks a lot

ebobnar
Jul 20 '05 #1
1 2037
This is a beautiful trick that works in lots of languages, you steal
control of the writing function:

<script type="text/javascript">
var write_output = "";
var document_write = document.write;
document.write = function( )
{
for( var i = 0; i < arguments.length; i ++ )
write_output += arguments[ i ].toString( );
};
</script>
<script type="text/javascript" src="look_at_me_I'm_an_ad.js"></script>
<script type="text/javascript">
document.write = document_write;
// Now you can read write_output
</script>

Have fun and good luck socking it to the crappy-ad-writing man.
..Brian
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jerrygarciuh | last post by:
Hello, I have a client who has decided to output the OO PHP/mySQL site I have made for them onto a cd. I realize that $html = include('somefile.php'); gets 1 for success as its return value....
4
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
5
by: Moosebumps | last post by:
I have a large set of Python scripts that interface with command line utilities (primarily Perforce). I am currently capturing ALL the text output in order to get results and such. I am using the...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
2
by: Ken Cox - Microsoft MVP | last post by:
I'm trying to find a way to program in ASP.NET 2.0 but capture the HTML output. I found the following routine in ASP.NET 2.0 Cookbook from O'Reilly. It doesn't work if I include a server-side...
6
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely...
1
by: Falcolas | last post by:
I have a rather strange situation, and I'm not sure my brief experience of Python will let me handle it properly. The situation is this: I have a Java class "X" which I need to call in a Jython...
2
by: gopala | last post by:
Hi, I am pretty new to python but i do have experience with c++. As a part of learning exercise i wrote a python script to insert beautifying comments(with name, problem...) to our lab program...
2
by: jallam | last post by:
Hi, I have a Python script to upload the Invoice data which is in .csv file to OTM (GLOG) system. I'm running this script using the command(given below) using a shell script and capturing the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.