Objectif 将监控一堆网站并在调用特定广告标签时自动截取屏幕截图(先前定义,属于新广告系列)
问问题
3020 次
1 回答
1
调用特定广告代码时自动截取屏幕截图
当您说“调用”特定广告代码时,我不太确定您的意思。你这么说是什么意思?
如果我对您的理解正确,您似乎想要捕获显示在网站上的广告。如果这是正确的理解,那么您可以保存广告的 HTML 并稍后“重播”它。您必须检查 HTML 中的某些标签才能检测广告是否正在展示。
因此,让我们看看 Google 广告是如何运作的。假设您搜索关键字“牙医”:http ://www.google.com/search?hl=en&q=dentist
首先,您必须检测是否存在广告,并且在 Google 上最常见的显示方式是使用<div id="tads">
div。如果您查看 HTML,div 标签将如下所示:
<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>
如果您获取父节点中的所有 HTML,将其放在一些<html></html>
标签的中间,然后将其保存到文件中,那么您实际上就是制作了广告的副本。当您打开保存的页面时,您会看到广告(尽管它没有任何漂亮的格式):
<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> - <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='<link rel="dns-prefetch" href="//www.1800dentist.com">';"><a href="/aclk?sa=L&ai=Cu5IzNnM5T8HqDIim0AHGz6iiCPbdxPwBloiAlyTFyIEGCAAQASgDUNLTqqr8_____wFgyYb_h_Cj7BLIAQGqBBpP0ABwNg99ODa1d9-oVCTsURJpLuG3eTRXOw&sig=AOD64_0uU8rB28uqqP0vfjhLb1rr4cwJAg&ved=0CBAQ0Qw&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. <a class="fl" href="#">Undo</a></div></div><span class="ac">Call or Visit 1-800-<b>DENTIST</b>® Today! </span><div><div style="margin-bottom:0px;margin-top:4px" class="oslk osi"><a href="/aclk?sa=L&ai=CyFBVNnM5T8HqDIim0AHGz6iiCPbdxPwBloiAlyTFyIEGCAAQASgDUOP89dL6_____wFgyYb_h_Cj7BLIAQGqBBpP0ABwNg99ODa1d9-oVCTsURJpLuG3eTRXO_oFCQgDEKbLnUMYAQ&ctype=4&sig=AOD64_2KcTwoGvsakHOnABv0GvJTyXkfHg&ved=0CAsQwgUoAA&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&ai=CxktKNnM5T8HqDIim0AHGz6iiCPbdxPwBloiAlyTFyIEGCAAQASgDUOL_t8EBYMmG_4fwo-wSyAEBqgQaT9AAcDYPfTg2tXffqFQk7FESaS7ht3k0Vzv6BQkIAxCmy51DGAI&ctype=4&sig=AOD64_0cHm2qsUVFET1ebqMN8f1qdn9cog&ved=0CAwQwgUoAQ&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='<link rel="dns-prefetch" href="//dentalsalon.com">';"><a href="/aclk?sa=l&ai=CrohpNnM5T8HqDIim0AHGz6iiCP_r_dQBu-WDqRCMhe4ECAAQAigDULzY_7P-_____wFgyYb_h_Cj7BKgAfWJ4_MDyAEBqgQdT9AAZF8NfTs2tT_fF2GUUAyBnPhpVvtRn2qKVWE&sig=AOD64_0JHw744mqzP1Ep2tAqycGZg0sejA&ved=0CBcQ0Qw&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. <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="google.adPing" href="http://maps.google.com/maps?hl=en&um=1&ie=UTF-8&daddr=Suite+800,+939+W+North+Ave,+Chicago,+IL&f=d&saddr=&iwstate1=dir:to&fb=1&geocode=3891923684064231596,41.910331,-87.652690&sa=X&ei=NnM5T9nSC-r20gGymeXFAg&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='<link rel="dns-prefetch" href="//www.BigSmileDental.com">';"><a href="/aclk?sa=l&ai=CXId8NnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQn4m4vP7_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV&sig=AOD64_3TlJu1Y44lD2JjEEkFLOsFSFZPZg&ved=0CCEQ0Qw&adurl=http://www.BigSmileDental.com" id="pa3">Big Smile Dental - $1 Exam & 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. <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&ai=CiPnsNnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQ1vWs8QNgyYb_h_Cj7BKgAY-L8-4DyAEBqgQcT9BAb3QMfTo-tYfclquXIovqnapwIBoIWQdnlfoFCQgDEIuk8yMYAQ&ctype=4&sig=AOD64_1nA5osjgI5obezQCRjLFRva-JxqQ&ved=0CBoQwgUoAA&adurl=http://www.bigsmiledental.com/porcelain_veneers.php">Porcelain Veneers</a> - <a href="/aclk?sa=l&ai=CmAknNnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQzq2Mgvz_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV-gUJCAMQi6TzIxgC&ctype=4&sig=AOD64_1gbgrRWKSSEBNajdaYaf3w7uXhEA&ved=0CBsQwgUoAQ&adurl=http://www.bigsmiledental.com/invisalign/index.html">Invisalign</a> - <a href="/aclk?sa=l&ai=CPiH-NnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQ56qAgvz_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV-gUJCAMQi6TzIxgD&ctype=4&sig=AOD64_0LeYmv1UwfXkkdixFJwQ1lxynVIg&ved=0CBwQwgUoAg&adurl=http://www.bigsmiledental.com/1_britesmile.php">Teeth Whitening</a> - <a href="/aclk?sa=l&ai=C87tmNnM5T8HqDIim0AHGz6iiCM3ptXjzxr-0F9OQ_QUIABADKANQlb_v2f3_____AWDJhv-H8KPsEqABj4vz7gPIAQGqBBxP0EBvdAx9Oj61h9yWq5cii-qdqnAgGghZB2eV-gUJCAMQi6TzIxgE&ctype=4&sig=AOD64_14t0h2fqBY_mFSz1f-fh4v177u5g&ved=0CB0QwgUoAw&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>
最后,如果您想要漂亮的格式,请参考Google 的样式表,现在您拥有与 Google 显示的广告几乎相同的副本。
注意事项:
- 每个广告商(Google、Bing、Yahoo 等)都有不同的格式,因此您可能必须为要监控的每个广告商执行上述操作。
- 即使在广告商内部,广告也可能因显示广告的浏览器而异(谷歌在 iphone 上显示的广告与在 android 手机上显示的广告不同)。
最后,由于我已经在一家提供广告捕获服务(以及更多服务)的公司工作,我不妨插入我们的解决方案。
我们有几个示例说明广告在捕获后的外观,包括以下示例:
于 2012-02-13T20:45:19.903 回答