php/curl没有返回正确的数据 [英] php/curl not returning correct data
问题描述
这里是一些测试代码的一小部分,只需转到
请参阅此处 [
但是,当我查看结果时,这并不是我想要的.如果您在结果中查找字符串
< span class = fullstory>联合国人道主义官员呼吁在海地开展大规模动员活动""
您可以在大规模动员活动"文本周围看到两个问号.
如果您访问实际的网站,问号将显示为左右一对引号,当您从站点查看源代码时,这会反映出来...
< span class = fullstory>联合国人道主义官员呼吁在海地开展大规模动员活动""
我想知道如何获取双引号而不是我看到的问号.
所有建议均感激不尽.
新年快乐!"
url ="http://www.un.org/apps/news/story.asp?NewsID=37180& ; Cr = Haiti& Cr1 =;
curl = curl_init(); //初始化curl句柄 curl_setopt(
curl,CURLOPT_URL,
Here''s a small sample of some test code that simply goes to
See here[^]
and pulls in the specified web page.
<<pre lang="php">?php $url = "http://www.un.org/apps/news/story.asp?NewsID=37180&Cr=Haiti&Cr1="; $curl = curl_init(); // initialize curl handle curl_setopt($curl, CURLOPT_URL, $url); // set url to post to curl_setopt($curl, CURLOPT_FAILONERROR, 1); curl_setopt($curl, CURLOPT_COOKIESESSION, TRUE); // since we reuse now curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($curl, CURLOPT_TIMEOUT, 20); // times out after 20 seconds curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; U; en; rv:1.8.0) Gecko/20060728 Firefox/1.5.0" ); $result = curl_exec($curl); // run the whole process print $result; <
When I look at the result, however, it''s not quite what I''m wanting. If you look in the results for the string
"<span class=fullstory>United Nations humanitarian officials are calling for ?massive mobilization activities? in Haiti"
you can see the two question marks surrounding the text "massive mobilization activities".
If you go to the actual website, the question marks are rendered as a pair of left- and right- quotation marks, and this is reflected when you view the source code from the site ...
"<span class=fullstory>United Nations humanitarian officials are calling for "massive mobilization activities" in Haiti"
I''d like to know how I can grab the double quotes rather than the question marks that I''m seeing.
All suggestions gratefully accepted.
And happy new year to y''all
url = "http://www.un.org/apps/news/story.asp?NewsID=37180&Cr=Haiti&Cr1=";
curl = curl_init(); // initialize curl handle curl_setopt(
curl, CURLOPT_URL,
这篇关于php/curl没有返回正确的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!