Пример #1
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var          ahitems = new AutoHintItems();
            const string api     = "https://capi-v2.sankakucomplex.com";

            Net = Net == null ? new NetDocker(Settings, api) : Net.CloneWithOldCookie();
            var pairs = new Pairs
            {
                { "lang", "en" },
                { "tag", para.Keyword.ToEncodedUrl() },
                { "target", "post" },
                { "show_meta", "1" }
            };
            var json = await Net.GetJsonAsync($"{api}/tags/autosuggestCreating", token, pairs);

            foreach (var jitem in Extend.CheckListNull(json))
            {
                var ahitem = new AutoHintItem();
                ahitem.Word  = $"{jitem.name}";
                ahitem.Count = $"{jitem.count}";
                ahitems.Add(ahitem);
            }

            return(ahitems);
        }
Пример #2
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var ahis     = new AutoHintItems();
            var jsonlist = await new NetDocker(Settings).GetJsonAsync(GetHintQuery(para), token);

            foreach (var item in jsonlist)
            {
                ahis.Add(new AutoHintItem
                {
                    Word = $"{item}".Replace("\"", "")
                });
            }
            return(ahis);
        }
Пример #3
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var ahis     = new AutoHintItems();
            var jsonlist = await new NetOperator(Settings).GetJsonAsync(GetHintQuery(para), token);

            foreach (var item in Extend.GetList(jsonlist))
            {
                ahis.Add(new AutoHintItem
                {
                    Word  = $"{item.value}",
                    Count = $"{item.post_count}"
                });
            }
            return(ahis);
        }
Пример #4
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var list = new AutoHintItems();
            var net  = new NetOperator(Settings);

            switch (SiteType)
            {
            case SiteTypeEnum.Xml:
                var xml = await net.GetXmlAsync(GetHintQuery(para), token);

                if (xml == null)
                {
                    return(list);
                }
                var root = xml.SelectSingleNode("tags");
                if (root?.ChildNodes == null)
                {
                    return(list);
                }
                foreach (XmlElement child in root.ChildNodes)
                {
                    list.Add(new AutoHintItem
                    {
                        Word  = child.GetAttribute("name"),
                        Count = child.GetAttribute("count")
                    });
                }

                return(list);

            case SiteTypeEnum.Json:
                var json = await net.GetJsonAsync(GetHintQuery(para), token);

                foreach (var item in Extend.GetList(json))
                {
                    list.Add(new AutoHintItem
                    {
                        Word  = $"{item.name}",
                        Count = $"{item.post_count}"
                    });
                }
                return(list);
            }

            return(list);
        }
Пример #5
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            if (AutoHintNet == null)
            {
                AutoHintNet = new NetDocker(Settings, HomeUrl);
            }
            AutoHintNet.SetReferer($"{HomeUrl}/?lang=zh_CN");
            //AutoHintNet.Client.DefaultRequestHeaders.Add("content-type", "multipart/form-data; boundary=----WebKitFormBoundaryzFqgWZTqudUG0vBb");
            var re      = new AutoHintItems();
            var mulform = new MultipartFormDataContent("----WebKitFormBoundaryzFqgWZTqudUG0vBb");
            var content = new FormUrlEncodedContent(new Pairs
            {
                { "tag", para.Keyword.Trim() }
            });

            mulform.Add(content);
            var url      = $"{HomeUrl}/pictures/autocomplete_tag";
            var response = await AutoHintNet.Client.PostAsync(url, mulform, token);

            // todo 这里post数据获取失败,希望有大神能够解决
            if (!response.IsSuccessStatusCode)
            {
                return(new AutoHintItems());
            }
            var txt = await response.Content.ReadAsStringAsync();

            //JSON format response

            dynamic json = JsonConvert.DeserializeObject(txt);
            dynamic list = ((JProperty)json).Value;

            foreach (var item in list)
            {
                re.Add(new AutoHintItem
                {
                    Word  = $"{item.t}".Replace("<br>", "").Replace("</br>", ""),
                    Count = $"{item.c}"
                });
            }

            return(re);
        }
Пример #6
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var items  = new AutoHintItems();
            var url    = $"{HomeUrl}/suggest?limit=8&q={para.Keyword}";
            var txtres = await Net.Client.GetAsync(url, token);

            var txt = await txtres.Content.ReadAsStringAsync();

            var lines = txt.Split('\n');

            for (var i = 0; i < lines.Length && i < 8; i++)
            {
                if (lines[i].IsEmpty())
                {
                    continue;
                }
                items.Add(lines[i].Substring(0, lines[i].IndexOf('|')).Trim());
            }
            return(items);
        }
Пример #7
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            if (AutoHintNet == null)
            {
                AutoHintNet = new NetOperator(Settings, HomeUrl);
                AutoHintNet.SetReferer(HomeUrl);
            }
            var items = new AutoHintItems();

            if (para.SubMenuIndex != 0 && para.SubMenuIndex != 5)
            {
                return(items);
            }
            var url   = $"{HomeUrl}/rpc/cps.php?keyword={para.Keyword}";
            var jList = await AutoHintNet.GetJsonAsync(url, token);

            foreach (var obj in Extend.GetList(jList?.candidates))
            {
                items.Add($"{obj.tag_name}");
            }
            return(items);
        }
Пример #8
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            if (Net == null)
            {
                Net = new NetDocker(para.Site.Settings);
            }
            //type 1 tag 2 source 3 artist | chara no type
            var items = new AutoHintItems();

            //chara without hint
            if (para.SubMenuIndex == 3)
            {
                return(items);
            }
            var pairs = new Pairs
            {
                { "mode", "tag_search" },
                { "tags", para.Keyword },
                { "type", $"{para.SubMenuIndex + 1}" }
            };
            var url = $"{HomeUrl}/httpreq.php{pairs.ToPairsString()}";
            var res = await Net.Client.GetAsync(url, token);

            var txt = await res.Content.ReadAsStringAsync();

            var lines = txt.Split('\n');

            for (var i = 0; i < lines.Length && i < 8; i++)
            {
                if (lines[i].Trim().Length > 0)
                {
                    items.Add(new AutoHintItem
                    {
                        Word = lines[i].Trim().Delete("\"")
                    });
                }
            }
            return(items);
        }
Пример #9
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            //http://www.zerochan.net/suggest?q=tony&limit=8
            if (!IsLogon)
            {
                Login(token);
            }
            var re = new AutoHintItems();

            if (!IsLogon)
            {
                return(re);
            }
            var url = $"{HomeUrl}/suggest?limit=15&q={para.Keyword}";

            Net.Client.DefaultRequestHeaders.Referrer = new Uri(HomeUrl);
            var res = await Net.Client.GetAsync(url, token);

            var txt = await res.Content.ReadAsStringAsync();

            var lines = txt.Split('\n');

            foreach (var h in lines)
            {
                //Tony Taka|Mangaka|
                var word = h.Contains("|") ? h.Substring(0, h.IndexOf('|')).Trim() : h;
                if (!word.IsEmpty())
                {
                    re.Add(new AutoHintItem {
                        Word = word
                    });
                }
            }

            return(re);
        }
Пример #10
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var net   = new NetOperator(para.Site.Settings);
            var pairs = new Pairs
            {
                { "limit", "15" },
                { "order", "count" },
                { "name", para.Keyword }
            };
            var query = $"{HomeUrl}/tag.json{pairs.ToPairsString()}";
            var json  = await net.GetJsonAsync(query, token);

            var items = new AutoHintItems();

            foreach (var item in Extend.GetList(json))
            {
                var hintItem = new AutoHintItem();
                hintItem.Count = $"{item.count}";
                hintItem.Word  = $"{item.name}";
                items.Add(hintItem);
            }

            return(items);
        }