Пример #1
0
        public static async Task <DCInsideComment> GetComments(string gall_id, string article_id, string page)
        {
            var nt = NetTask.MakeDefault("https://gall.dcinside.com/board/comment/");

            nt.Headers = new Dictionary <string, string>()
            {
                { "X-Requested-With", "XMLHttpRequest" }
            };
            nt.Query = new Dictionary <string, string>()
            {
                { "id", gall_id },
                { "no", article_id },
                { "cmt_id", gall_id },
                { "cmt_no", article_id },
                { "e_s_n_o", DCInsideManager.Instance.ESNO },
                { "comment_page", page }
            };
            return(JsonConvert.DeserializeObject <DCInsideComment>(await NetTools.DownloadStringAsync(nt)));
        }
Пример #2
0
        public static List <string> DownloadStrings(List <string> urls, string cookie = "", Action complete = null)
        {
            var interrupt = new ManualResetEvent(false);
            var result    = new string[urls.Count];
            var count     = urls.Count;
            int iter      = 0;

            foreach (var url in urls)
            {
                var itertmp = iter;
                var task    = NetTask.MakeDefault(url);
                task.DownloadString         = true;
                task.CompleteCallbackString = (str) =>
                {
                    result[itertmp] = str;
                    if (Interlocked.Decrement(ref count) == 0)
                    {
                        interrupt.Set();
                    }
                    complete?.Invoke();
                };
                task.ErrorCallback = (code) =>
                {
                    if (Interlocked.Decrement(ref count) == 0)
                    {
                        interrupt.Set();
                    }
                };
                task.Cookie = cookie;
                Scheduler.Add(task);
                iter++;
            }

            interrupt.WaitOne();

            return(result.ToList());
        }
Пример #3
0
 public static string DownloadString(NetTask task)
 {
     return(DownloadStringAsync(task).Result);
 }
Пример #4
0
 public static string DownloadString(string url)
 {
     return(DownloadStringAsync(NetTask.MakeDefault(url)).Result);
 }