1

需要大写元标记的内容,该站点有超过 75 个文件,我真的很想手动完成。尝试使用 simple_html_dom,但找不到方法....有什么提示吗?

这是标签的一个例子:

<meta name="description" content="Aproveche nuestras ofertas y sea el primero en alcanzar nuestro objetivo de promociones !!!!!" />

这就是我一直在尝试做的,但想不出如何解决它:

$scraptedText =  file_get_html('../index.html'); 
$change = split('<meta name="description"', $scraptedText);
$change = split(' />',  $change[1]);
$change = $change[0];
$change = strtoupper($change);

谢谢!!

4

3 回答 3

0

使用 jQuery,您可以执行以下操作:

var meta = $('meta').attr('content');
$('meta').attr('content', meta.toUpperCase());
于 2012-11-15T00:37:54.537 回答
0

对不起,对于那个反问题:

但是为什么要使描述大写呢?

一些(大)搜索引擎可以在“大喊大叫”的情况下暂停您的服务。(或者你有没有看到一个网站@google 这样做(大写的喊叫)?还是我误解了?

否则,辅助方法可以解决您的问题(我使用 Zend 框架并使用了他们的 View_Helper: http: //framework.zend.com/manual/1.8/en/zend.view.helpers.html#zend.view.helpers

它是免费的,可以通过包含实现)

希望这可以帮助

于 2012-11-15T00:44:00.323 回答
0

查看preg_replace_callback

function matchToUpper($matches) {
    return str_replace($matches[1], strtoupper($matches[1]), $matches[0]);
}
$scraptedText = preg_replace_callback('%<meta name="description" content="(.*?)" />%', 'matchToUpper', $scraptedText);
于 2012-11-15T00:44:32.787 回答