下载页面中广告的脚本
我想下载页面中的广告。任何人都可以给我一些如何做到这一点的想法。或者你知道有什么插件可以做到这一点。我研究了阻止广告的插件,并尝试使用它们来下载广告。
当我在浏览器中打开页面时,我需要下载该页面上存在的所有广告。那么我需要编写一个插件或附加组件来做到这一点吗?我需要为我的一个项目收集广告。
I want to downlaod the ads present in a page. Can anyone give me some ideas how to do this.Or do you know any plugin which does this. I looked into plugins which block ads and was trying to use them to download the ads.
When I open a page in a browser i need to download all the ads which are present on that page. So I need to write a plugin or an add on to do that? I need to collect ads for one of my project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定您将使用什么逻辑来识别哪些图像/对象是广告,哪些不是,但您可以使用 GreaseMonkey Firefox 插件来编写此脚本。
简而言之,您必须循环遍历所有可疑元素(我们会说图像和对象)并检查它们的 src 属性。如果某个元素被识别为广告,则将该 URL 传递到网络服务器(可以是本地主机或在线托管),该服务器将抓取文件并保存它。
否则,我非常确定 javascript/chrome/XUL 的安全限制是这样的,您将无法从网上获取任意内容并静默写入本地计算机的硬盘驱动器。想象一下这将带来的安全风险!
I am not certain exactly what logic you'd use to identify which images/objects are ads and which are not, but you could use the GreaseMonkey Firefox add-on to script this.
In a nutshell, you'd have to loop through all suspect elements (we'll say images and objects) and check their
src
property. If an element is identified as an advertisement, pass that URL on to a webserver (could be localhost or hosted online) that will grab the file and save it.Otherwise, I am pretty certain that the security restrictions of javascript/chrome/XUL are such that you aren't going to be able to take arbitrary content from online and write to the the local computer's hard drive silently. Imagine the security risks that would entail!
好吧,您可以尝试制作某种在每个页面加载时触发的浏览器插件,然后使用 AdBlock 的列表,例如 这个来识别广告并下载它们。缺点是您将制作一些极其依赖于浏览器的东西,并且您必须解析相同类型的规则。
Well, you could try and make some kind of browser add-on which triggers on each page load, and then use AdBlock's lists such as this one to identify advertisements and download them. Downside is you would be making something extremely browser-dependent and you would have to parse the same kind of rules.