捕获和转换Web的工具

如何禁用JavaScript内联弹出窗口?

某些网页包含不需要的内联 JavaScript 弹出窗口,这些弹出窗口出现在我们生成的屏幕截图中 的API在线截图工具。 隐藏这些弹出窗口的最可靠技术是指定要隐藏的弹出窗口的 HTML 元素。 下面是我们要删除的内联弹出窗口的 HTML 片段。

<div class="ArevicoModal-bg ArevicoModal-iframe" style="display: block;"></div>
<div class="ArevicoModal ArevicoModal-iframe" style="display: block;">
 <div class="ArevicoModal-content">
  <span class="ArevicoModal-close-icon ArevicoModal-close"></span>
  <div id="arvlbdata" style="overflow:visible;width:400px;height:250px;" class="ArevicoModal-inner">
   <h2>Sign up now!!</h2>
  </div>
 </div>
</div>

因此,要删除此弹出窗口,我们需要使用元素隐藏所有阻止页面的弹出元素 CSS选择器。 在这种情况下 .ArevicoModal-bg.ArevicoModal。 您可以使用网络浏览器的开发人员工具找出需要删除的 HTML 元素。 隐藏的例子 .ArevicoModal-bg.ArevicoModal 下面显示了每个 API 的 HTML 元素。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
ImageOptions options = new ImageOptions();
options.HideElement = ".ArevicoModal-bg,.ArevicoModal";
grabzIt.URLToImage("http://www.spacex.com", options);
grabzIt.SaveTo("spacex.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
ImageOptions options = new ImageOptions();
options.hideElement(".ArevicoModal-bg,.ArevicoModal");
grabzIt.URLToImage("http://www.spacex.com", options);
grabzIt.SaveTo("spacex.jpg");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.5.2/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com", 
	{"hide", ".ArevicoModal-bg,.ArevicoModal"}).Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
client.url_to_image("http://www.spacex.com", 
	{"hideElement", ".ArevicoModal-bg,.ArevicoModal"});
client.save_to("spacex.jpg", function (error, id){
    if (error != null){
        throw error;
    }
});
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = GrabzItImageOptions->new();
$options->hideElement(".ArevicoModal-bg,.ArevicoModal");
$grabzIt->URLToImage("http://www.spacex.com", $options);
$grabzIt->SaveTo("spacex.jpg");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = new \GrabzIt\GrabzItImageOptions();
$options->setHideElement(".ArevicoModal-bg,.ArevicoModal");
$grabzIt->URLToImage("http://www.spacex.com", $options);
$grabzIt->SaveTo("spacex.jpg");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzItImageOptions.GrabzItImageOptions()
options.hideElement = ".ArevicoModal-bg,.ArevicoModal"
grabzIt.URLToImage("http://www.spacex.com", options)
grabzIt.SaveTo("spacex.jpg")
https://api.grabz.it/services/convert?key=Sign in to view your Application Key&format=jpg&hide=.ArevicoModal-bg%2C.ArevicoModal&url=https%3A%2F%2Fspacex.com%2F
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzIt::ImageOptions.new()
options.hideElement = ".ArevicoModal-bg,.ArevicoModal"
grabzIt.url_to_image("http://www.spacex.com", options)
grabzIt.save_to("spacex.jpg")

其他技术

某些弹出窗口是通过 cookie 控制的,因此,如果您为该域设置了正确的 cookie 值,则弹出窗口可能不再出现。 这可以是 手动完成 或通过启用自动 用户cookie行为 模式。

为此,请访问网页并打开浏览器的开发人员工具功能,以便您可以查看网页上存在哪些 cookie。 现在关闭弹出窗口。 如果出现新的 cookie,请刷新页面。 如果弹出窗口不再出现,请复制出现的 cookie 的详细信息并将其添加到您的 自定义Cookie。 不过,最好给它一个较长的有效期(也许是未来 10 年),这样 cookie 就不会被删除。

另一个潜在的解决方案是使用 搜索引擎 用户代理,通过设置“请求为”参数。 根据网站的编写方式,可能会导致弹出窗口不出现。