473,624 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2056
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.lengt h; 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
1958
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. In what manner can I access my files so what would be output to the browser from 'someFile.php?id=1213'
4
8130
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: ------------------------------------- test3.pl ------------------------------------- print "PERL Hello from Perl! (plain print)<br>\n"; print STDERR "PERL This is text sent to STDERR<br>\n"; $output="PERL Some output:<br>\n"; for ($i=0; $i<5; $i++) {
5
2131
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 popen functions to get the stdout, stderr streams. However, some of the operations take a really long time (copying large files over the network). If you run Perforce directly (or through os.system, which doesn't return text output), it shows...
1
5376
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 application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
2
1718
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 dropdownlist control on the page. The error is RegisterForEventValidation can only be called during Render(); Any ideas? Ken Microsoft MVP
6
2260
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 PC, but has a significant number of Macs running OS X, too. Googling around quickly turns up IM Grabber for the PC, which would seem to be just what they need. But there is no equivalent to be found for OS X. So if anyone knows of any such...
1
1705
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 script. The output of "X" is sent to stdout using the java call System.out. I need to capture this output, and preform tests on it in the Jython script. My first pass at a design involves two jython scripts. One (we'll call it "Y") whose sole...
2
1571
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 source files (c language). The script is working for most of the cases. The problem is i also need to append the test output of the lab programs to the corresponding source files(again the output should be added as a beautified comment). The lab...
2
2957
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 output to a file (which we are refering as a log). python TestInvoiceTransform.py -glUserGid <user> -glPassword <password> -inputFileName TestInvoice.csv -hostname <host url> -mailto <mail id> -smtphost amermsx.med.ge.com > test.log The output is...
0
8234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8677
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8620
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.