首页 \ 问答 \ cUrl打开多个URL(cUrl multiple URL open)

cUrl打开多个URL(cUrl multiple URL open)

$query = 'SELECT * FROM `chat` LIMIT 0, 24334436743;'; 
$result = mysql_query($query);
while($row = mysql_fetch_array( $result )) {
$URL = $row['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$URL");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "user=unrevoked clarity&randominfo=hi");
curl_exec ($ch);
curl_close ($ch);
   }





//curl_close ($ch);
} 

好吧,上面的片段是我从数据库中提取了一大堆URL,我正在尝试向每个URL发送数据。 但它似乎打破了页面(即使只有一个或两个URL)。 是否有内置系统来处理这个或什么?


$query = 'SELECT * FROM `chat` LIMIT 0, 24334436743;'; 
$result = mysql_query($query);
while($row = mysql_fetch_array( $result )) {
$URL = $row['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$URL");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "user=unrevoked clarity&randominfo=hi");
curl_exec ($ch);
curl_close ($ch);
   }





//curl_close ($ch);
} 

Alright the above snippet is me pulling a whole bunch of URL's from a database and I am trying to send data to each of them. But it seems to gum the page up (even with only one or two URL's). Is there a built in system to handle this or something?


原文:https://stackoverflow.com/questions/5215157
更新时间:2024-01-29 16:01

最满意答案

我在我的个人项目中使用JSON.NET,但是使用方括号语法反序列化,如下所示:

Id = jsonResult["object_id"].ToObject<int>(),

要实际获取JSON对象,我执行此操作:

var response = await client.GetStringAsync(parameters);
var jsonResult = JToken.Parse(response)["results"].Children();

在对使用JSON.NET的不同方法进行了大量研究之后,我采用了这种方法。 阅读本文后,我认真考虑走动态路线: http//www.west-wind.com/weblog/posts/2012/Aug/30/Using-JSONNET-for-dynamic-JSON-parsing

但是,最后我决定不使用动态对象,因为当我使用方括号语法填充我的普通对象时,我立即返回强类型环境,其中intellisense将开始捕获我可能犯的任何错误。 我将它与LINQ查询结合起来,并在相对较少的行中填充一组相当复杂的对象。

对我来说,动态对象是反序列化过程中的一个弱类型步骤,我希望尽可能避免。


I use JSON.NET in a personal project of mine, but deserialize using square bracket syntax like this:

Id = jsonResult["object_id"].ToObject<int>(),

To actually get the JSON object I do this:

var response = await client.GetStringAsync(parameters);
var jsonResult = JToken.Parse(response)["results"].Children();

I adopted this methodology after doing a good bit of research into the different ways to use JSON.NET. I seriously considered going the dynamic route after reading this article: http://www.west-wind.com/weblog/posts/2012/Aug/30/Using-JSONNET-for-dynamic-JSON-parsing

However, in the end I decided against dynamic objects because when I fill my normal objects with the square bracket syntax I return immediately to a strongly-typed environment where intellisense will begin to catch any errors I may make. I combine this with a LINQ query and fill a set of fairly complex objects in a relatively few number of lines.

For me, dynamic objects are one more weakly-typed step in the deserialization process that I prefer to avoid if possible.

相关问答

更多
  • 对json字符串或数组使用相同字段的最简单方法可能是使用Object字段。 此解决方案不需要自定义序列化程序和反序列化程序。 以下是Jackson注释的示例类: @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) public class NetworkStatistics { private String apiVersion; private String latitude; private Stri ...
  • 我的假设是错误的,我已经打印了Json。 我刚刚发布了javascript对象。 至于无法发送它是因为我的html表单中的multipart / formdata发送它通过restangular它变成application / json。 在这个重新讨论的问题上,我发现了如何在Formdata中打包它。 My assumption that was wrong that I was already printing the Json. I was just posting the javascript ob ...
  • 将ExternalUrls声明为 [JsonProperty("external_urls")] public Dictionary ExternalUrls { get; set; } declare ExternalUrls as [JsonProperty("external_urls")] public Dictionary ExternalUrls { get; set; }
  • 你的JSON是什么样的? {"Filter": "[{'Vehicle':'5010','Users':'2279'}]"} 要么 [{'Vehicle':'5010','Users':'2279'}] 要么 {[Filter, [{'Vehicle':'5010','Users':'2279'}]]} ??? 例如,您可以尝试这样的事情: //JSON looks like this {"Filter": "[{'Vehicle':'5010','Users':'2279'}]"} var jso ...
  • 橡胶与同事一起解决这个问题后,上述行为对我来说是有道理的。 在不知道它反序列化的对象类型的情况下,Json.Net真的无法知道Sons或Bros属性不是包含“{”$ ref“:”1“}”的字符串属性......怎么可能呢? 当然它反错误地反序列化了。 它必须知道目标类型,以便知道何时进一步反序列化对象的属性。 最终得到一个动态对象,其字符串属性包含对象引用的Json表示。 当模型绑定器尝试使用此动态对象在具体类型上设置值时,它找不到匹配项,并且最终得到目标的空实例。 Jason Butera对这个问题的回答 ...
  • 不,如果没有创建自己的包装器,这是不可能的: “代理”WinRT对象,并使该代理侦听来自WinRT对象的事件并设置属性 从WinRT层创建看起来像可观察和投射的东西(例如,它具有“绑定”功能,可以进行回调等。 No, this isn't possible without creating your own wrapper that would either: "Proxy" the WinRT object, and make that proxy listen for events from the W ...
  • 我在我的个人项目中使用JSON.NET,但是使用方括号语法反序列化,如下所示: Id = jsonResult["object_id"].ToObject(), 要实际获取JSON对象,我执行此操作: var response = await client.GetStringAsync(parameters); var jsonResult = JToken.Parse(response)["results"].Children(); 在对使用JSON.NET的不同方法进行了大量研究之后,我采 ...
  • 您的网址似乎返回压缩数据,HttpClient不知何故不理解这一点。 下面的代码修复了这个: public static async Task GetJsonString() { HttpClient client = new HttpClient(); string url = @"https://api.stackexchange.com/2.1/answers?fromdate=1349913600&order=desc&min=20&sort=votes&site=s ...
  • 创建一个像itemInfo这样的子结构: type itemInfo struct { Stat string `json:"stat"` Crit int `json:"crit"` } 然后在你的Item结构中 type Item struct { --snip-- Context string `gorm:"column:context" json:"context"` Stats []itemInfo `gorm:"column:stats" json ...
  • 关于我的评论,也许我们最好写下我的例子: string json = @"{""ABC"": 123, ""DEF"": 234}"; var employees = JsonConvert.DeserializeObject>(json).Select(x => new Employees() { employeeCode = x.Key, cityId = x.Value }); Regarding my comment maybe it us be ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。