开发者

How can Nokogiri extract the Charset encoding of a scraped HTML document?

开发者 https://www.devze.com 2023-01-17 17:45 出处:网络
Found a snippet tha开发者_Python百科t works for HTML Simple Dom Parser. $el=$html->find(\'meta[http-equiv=Content-Type]\',0);

Found a snippet tha开发者_Python百科t works for HTML Simple Dom Parser.

$el=$html->find('meta[http-equiv=Content-Type]',0);
$fullvalue = $el->content;
preg_match('/charset=(.+)/', $fullvalue, $matches);
echo $matches[1];

Can somebody help me to convert this so that this suits for Ruby and Nokogiri?


meta_encoding()

0

精彩评论

暂无评论...
验证码 换一张
取 消