用来抓取HTML和CSS样式的纯PHP解决方案是什么?
例如,抓取此页面
<!doctype html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<div id="success" class="alert alert-success" role="alert" style="font-size:30px">Success</div>id=success会返回的地方
<div style="color: rgb(60, 118, 61); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 30px; line-height: 42.8571434020996px; background-color: rgb(223, 240, 216);">Success</div>就像我手动复制了页面的那部分一样。
发布于 2015-04-07 12:09:19
如果我没弄错的话,您想用PHP将内联样式集添加到id "sucess“中。
您可以使用以下命令来做一些事情:
<?php
$inlineStyle = "color: rgb(60, 118, 61); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 30px; line-height: 42.8571434020996px; background-color: rgb(223, 240, 216);";
?>并将其添加到您的HTML标签上:
<div id="success" .... style="<?= $inlineStyle ?>"></div>https://stackoverflow.com/questions/29483481
复制相似问题