0

Objectif would be to monitor a bunch of websites and automatically take screenshots when a specific ad tag is called (previously defined, belonging to a new campaign)

Matthieu
  • 361
  • 2
  • 6
  • 16

1 Answers1

1

automatically take screenshots when a specific ad tag is called

I'm not really sure what you mean when you say that a specific ad tag is "called." What do you mean when you say that?

If I understand you correctly, you seem to want to capture an ad if it's displayed on a website. If that's the correct understanding then you can just save the HTML of an ad and "replay" it later. You do have to check for certain tags in the HTML in order to detect if an ad is showing.

So let's look at how things work on with Google ads. And let's say you search for the keyword "dentist": http://www.google.com/search?hl=en&q=dentist

First you have to detect that an ad exists and the most common way this is indicated on Google is with the <div id="tads"> div. If you look at the HTML, the div tag will look like this:

<div id="tads" class="c" style="margin:0 0 14px;padding-top:2px;padding-right:36px;padding-bottom:2px;padding-left:8px;min-height:0">
<h2 style="font-size:11px;font-weight:normal;margin:0 -35px 0 0;padding:1px 4px 0 0;text-align:right">
<ol style="padding:3px 0" onmouseover="return true">
<li class="taf">
    // collapsed html for the purposes of this example
<li class="tam">
    // collapsed html for the purposes of this example
<li class="tal">
    // collapsed html for the purposes of this example
</ol>
<div id="topDnsPrefetchHints">
</div>

If you take all the HTML in the parent node, plop it in the middle of some <html></html> tags, save it to a file and you would have essentially made a copy of the ad. When you open the saved page you will see the ad (although it will not have any of the pretty formatting):

<html>
<head>
</head>
<body>

<span style="margin-right:0" id="taw">   <div></div>  <div style="margin:0 0 14px;padding-top:2px;padding-right:36px;padding-bottom:2px;padding-left:8px;min-height:0" id="tads" class="c"><h2 style="font-size:11px;font-weight:normal;margin:0 -35px 0 0;padding:1px 4px 0 0;text-align:right">Ads<span>&nbsp;-&nbsp;<a onclick="google.x(this,function(){if(google.wta){google.wta.toggleLightbox(this,'0CAYQJw','0CAgQKQ',380);}});return false;" id="wtata" class="gl wtall" href="javascript:void(0)">Why these ads?</a><span style="display:none" class="wtalbc">These ads are based on your current search terms.<br><div style="padding-top:12px">Visit Google’s <a class="std gl wtaal" href="#">Ads Preferences Manager</a> to learn more or opt out.</div></span></span></h2><ol style="padding:3px 0" onmouseover="return true"><li class="taf"><div sig="1W8" cved="0CA8Qhw0wAQ" pved="0CA0QhQ0wAQ" class="vsc vsta"><h3 onmouseover="document.getElementById('topDnsPrefetchHints').innerHTML='&lt;link rel=&quot;dns-prefetch&quot; href=&quot;//www.1800dentist.com&quot;&gt;';"><a href="/aclk?sa=L&amp;ai=Cu5IzNnM5T8HqDIim0AHGz6iiCPbdxPwBloiAlyTFyIEGCAAQASgDUNLTqqr8_____wFgyYb_h_Cj7BLIAQGqBBpP0ABwNg99ODa1d9-oVCTsURJpLuG3eTRXOw&amp;sig=AOD64_0uU8rB28uqqP0vfjhLb1rr4cwJAg&amp;ved=0CBAQ0Qw&amp;adurl=http://www.1800dentist.com/lp/dentist/%3Fcid%3Don_ps_g_IL-Chicago-602-Search-GT_Dentist_txt%26dma%3D602%26kw%3Ddentist_e%26refcd%3DGO733T000000517170987s_dentist%26tsacr%3DGO9618667638" id="pa1">Find a Local <b>Dentist</b> - 24/7 Online Appointment Booking.</a></h3><div class="vspib" aria-label="Result details" role="button" tabindex="0"><div class="vspii"><div class="vspiic"></div></div></div><div><div class="kv"><cite>www.1800<b>dentist</b>.com/Chicago<b>Dentist</b></cite></div></div><div><div style="display:none" id="poAs0p1" class="esc slp">You +1'd this publicly.&nbsp;<a class="fl" href="#">Undo</a></div></div><span class="ac">Call or Visit 1-800-<b>DENTIST</b>&reg; Today! </span><div><div style="margin-bottom:0px;margin-top:4px" class="oslk osi"><a href="/aclk?sa=L&amp;ai=CyFBVNnM5T8HqDIim0AHGz6iiCPbdxPwBloiAlyTFyIEGCAAQASgDUOP89dL6_____wFgyYb_h_Cj7BLIAQGqBBpP0ABwNg99ODa1d9-oVCTsURJpLuG3eTRXO_oFCQgDEKbLnUMYAQ&amp;ctype=4&amp;sig=AOD64_2KcTwoGvsakHOnABv0GvJTyXkfHg&amp;ved=0CAsQwgUoAA&amp;adurl=http://www.1800dentist.com/lp/gentle-dentist/%3Fcid%3Don_ps_g_IL-Chicago-602-Search-GT_NA_stl%26kw%3Dfind%2Bgentle%2Bpain-free%2Bdentists%26refcd%3DGO733T000000517170987s_dentist%26tsacr%3DGO9618667638">Find Gentle Pain-Free Dentists</a> - <a href="/aclk?sa=L&amp;ai=CxktKNnM5T8HqDIim0AHGz6iiCPbdxPwBloiAlyTFyIEGCAAQASgDUOL_t8EBYMmG_4fwo-wSyAEBqgQaT9AAcDYPfTg2tXffqFQk7FESaS7ht3k0Vzv6BQkIAxCmy51DGAI&amp;ctype=4&amp;sig=AOD64_0cHm2qsUVFET1ebqMN8f1qdn9cog&amp;ved=0CAwQwgUoAQ&amp;adurl=http://www.1800dentist.com/lp/find-a-dentist/%3Fcid%3Don_ps_g_IL-Chicago-602-Search-GT_NA_stl%26kw%3Dfind%2Ba%2Bdentist%2Bonline%2Bfor%2Bfree!%26refcd%3DGO733T000000517170987s_dentist%26tsacr%3DGO9618667638">Find a Dentist Online for Free</a></div></div></div></li><li class="tam"><div sig="nxV" cved="0CBYQhw0wAg" pved="0CBQQhQ0wAg" class="vsc vsta"><h3 onmouseover="document.getElementById('topDnsPrefetchHints').innerHTML='&lt;link rel=&quot;dns-prefetch&quot; href=&quot;//dentalsalon.com&quot;&gt;';"><a href="/aclk?sa=l&amp;ai=CrohpNnM5T8HqDIim0AHGz6iiCP_r_dQBu-WDqRCMhe4ECAAQAigDULzY_7P-_____wFgyYb_h_Cj7BKgAfWJ4_MDyAEBqgQdT9AAZF8NfTs2tT_fF2GUUAyBnPhpVvtRn2qKVWE&amp;sig=AOD64_0JHw744mqzP1Ep2tAqycGZg0sejA&amp;ved=0CBcQ0Qw&amp;adurl=http://dentalsalon.com" id="pa2"><b>DENTIST</b> at Dental Salon - Super Convenient</a></h3><div class="vspib" aria-label="Result details" role="button" tabindex="0"><div class="vspii"><div class="vspiic"></div></div></div><div><div class="kv"><cite>www.dentalsalon.com/Great-Reviews</cite></div></div><div><div style="display:none" id="poAs0p2" class="esc slp">You +1'd this publicly.&nbsp;<a class="fl" href="#">Undo</a></div></div><span class="ac">Open 7 Days and Evenings - Affordable - 12 <b>Dentists</b> </span><div><div style="margin-bottom:0px;margin-top:0px">Suite 800, 939 W North Ave, Chicago, IL - 1 (312) 642-3370 - <a google.adping('t',2,11)"="" &&="" class="flonmousedown=&quot;google.adPing" href="http://maps.google.com/maps?hl=en&amp;um=1&amp;ie=UTF-8&amp;daddr=Suite+800,+939+W+North+Ave,+Chicago,+IL&amp;f=d&amp;saddr=&amp;iwstate1=dir:to&amp;fb=1&amp;geocode=3891923684064231596,41.910331,-87.652690&amp;sa=X&amp;ei=NnM5T9nSC-r20gGymeXFAg&amp;ved=0CBMQmxA">Directions</a></div></div></div></li><li class="tal"><div sig="ohs" cved="0CCAQhw0wAw" pved="0CB4QhQ0wAw" class="vsc vsta"><h3 onmouseover="document.getElementById('topDnsPrefetchHints').innerHTML='&lt;link rel=&quot;dns-prefetch&quot; href=&quot;//www.BigSmileDental.com&quot;&gt;';"><a href="/aclk?sa=l&amp;ai=CXId8NnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQn4m4vP7_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV&amp;sig=AOD64_3TlJu1Y44lD2JjEEkFLOsFSFZPZg&amp;ved=0CCEQ0Qw&amp;adurl=http://www.BigSmileDental.com" id="pa3">Big Smile Dental - $1 Exam &amp; X-Rays or Free Whitening</a></h3><div class="vspib" aria-label="Result details" role="button" tabindex="0"><div class="vspii"><div class="vspiic"></div></div></div><div><div class="kv"><cite>www.bigsmiledental.com</cite></div></div><div><div style="display:none" id="poAs0p3" class="esc slp">You +1'd this publicly.&nbsp;<a class="fl" href="#">Undo</a></div></div><span class="ac">As Seen on FoxNews (773)772-8400 </span><div><div style="margin-bottom:0px;margin-top:4px" class="oslk osi"><a href="/aclk?sa=l&amp;ai=CiPnsNnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQ1vWs8QNgyYb_h_Cj7BKgAY-L8-4DyAEBqgQcT9BAb3QMfTo-tYfclquXIovqnapwIBoIWQdnlfoFCQgDEIuk8yMYAQ&amp;ctype=4&amp;sig=AOD64_1nA5osjgI5obezQCRjLFRva-JxqQ&amp;ved=0CBoQwgUoAA&amp;adurl=http://www.bigsmiledental.com/porcelain_veneers.php">Porcelain Veneers</a> - <a href="/aclk?sa=l&amp;ai=CmAknNnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQzq2Mgvz_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV-gUJCAMQi6TzIxgC&amp;ctype=4&amp;sig=AOD64_1gbgrRWKSSEBNajdaYaf3w7uXhEA&amp;ved=0CBsQwgUoAQ&amp;adurl=http://www.bigsmiledental.com/invisalign/index.html">Invisalign</a> - <a href="/aclk?sa=l&amp;ai=CPiH-NnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQ56qAgvz_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV-gUJCAMQi6TzIxgD&amp;ctype=4&amp;sig=AOD64_0LeYmv1UwfXkkdixFJwQ1lxynVIg&amp;ved=0CBwQwgUoAg&amp;adurl=http://www.bigsmiledental.com/1_britesmile.php">Teeth Whitening</a> - <a href="/aclk?sa=l&amp;ai=C87tmNnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQlb_v2f3_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV-gUJCAMQi6TzIxgE&amp;ctype=4&amp;sig=AOD64_14t0h2fqBY_mFSz1f-fh4v177u5g&amp;ved=0CB0QwgUoAw&amp;adurl=http://www.bigsmiledental.com/dental-implants.php">Dental Implants</a></div></div></div></li></ol><div id="topDnsPrefetchHints"><link href="//www.1800dentist.com" rel="dns-prefetch"></div></div>  </span>
</body>
</html>

Finally, if you want the pretty formatting, then reference Google's style sheet and now you have an almost identical copy of the ad that Google is displaying.

Things to note:

  1. Every advertiser (Google, Bing, Yahoo, etc.) has a different format, so you may have to do the above for every advertiser you want to monitor.
  2. Even within advertisers, there may be variations on the ad depending on the browser that is displaying the ad (Google displays ads differently on iphones than they do for android phones).

Finally, since I already work for a company that provides the ad capturing service (and more), I might as well plug our solutions.

We have several examples on how the ads look once captured, including this one: enter image description here

Kiril
  • 39,672
  • 31
  • 167
  • 226
  • Thanks for your detailed answer ! I work for a BT ad-network (we have our own proprietary ad-server) and we would like to automatically take screenshots of our live campaigns (to send them to agencies & advertisers). So the 'crawler/script' could be able to monitor ~100 websites, detect when our script is called & take screenshot accordingly. One more thing : some campaigns are targeted against cookie value (behavior), so they might not appear on a lambda user. Is it a service your company could provide? Or would you know any script/tool to do this? Thanks – Matthieu Feb 14 '12 at 09:48
  • I don't have much experience with the actual ad network systems side, so what would you take a screenshot of when your script does get called? If somebody executes your script, then what would you show the agencies and advertisers? I'd have to check if we do anything with cookies, but I suspect we may not... however, I'm the wrong guy to ask about tools since we tend to build a lot of our stuff in-house. – Kiril Feb 14 '12 at 14:45
  • I would take a screenshot of the website as it is displayed in a user browser (where you can see the actual ad). So for example, the agency will see that the campaign is running on Yahoo (or on a bunch of websites in our ad-network) – Matthieu Feb 14 '12 at 16:36
  • Hmm, yah, taking an actual screenshot is challenging, but there are some resources: http://stackoverflow.com/questions/60455/take-a-screenshot-of-a-webpage-with-javascript and Google did a similar thing too: http://stackoverflow.com/questions/4912092/using-html5-canvas-javascript-to-take-screenshots – Kiril Feb 14 '12 at 16:50
  • P.S. We don't do anything with the cookies, since that would require us to model certain user profiles in order to show that the ad is showing and we don't see much value in that exercise. – Kiril Feb 14 '12 at 16:53