我有些时候通过curl方法获取url数据的问题特别是网站数据是阿拉伯语等其他语言我的curl函数是
function file_get_contents_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
//checking mime types
if(strstr($info,'text/html')) {
curl_close($ch);
return $data;
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
以及我如何获取数据
$html = file_get_contents_curl($checkurl);
$grid ='';
if($html)
{
$doc = new DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
@$title = $nodes->item(0)->nodeValue;
@$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('name') == …Run Code Online (Sandbox Code Playgroud) 我有一个带有maskedtextbox控件的Windows窗体应用程序,我只想接受字母值.
理想情况下,这将表现为按下除字母键之外的任何其他键将不产生结果或立即向用户提供关于无效字符的反馈.