Ejemplo n.º 1
0
        internal static string DiggStory(DiggStory diggStory)
        {
            HttpWebRequest req = CreateRequest("http://www.digg.com/diginfull", _cookies);

            PostData(req, "id=" + diggStory.id + "&row=" + diggStory.row + "&digcheck=" + diggStory.diggCheck);
            string responseString = GetResponseString(req);

            return(responseString);
        }
Ejemplo n.º 2
0
 internal void SetStory(DiggStory story)
 {
     _diggStory = story;
     Invoke(new MethodInvoker(InternalSetStory));
 }
Ejemplo n.º 3
0
        internal static DiggStory[] GetStories(string username, string password, string page) //page for future use
        {
            string url = "";

            switch (page)
            {
            case "Technology":
                url = "http://www.digg.com/view/technology";
                break;

            case "Science":
                url = "http://www.digg.com/view/science";
                break;

            case "World & Business":
                url = "http://www.digg.com/view/world_business";
                break;

            case "Videos":
                url = "http://www.digg.com/view/videos";
                break;

            case "Entertainment":
                url = "http://www.digg.com/view/entertainment";
                break;

            case "Gaming":
                url = "http://www.digg.com/view/gaming";
                break;

            default:
                url = "http://www.digg.com/";
                break;
            }

            //first login
            if (!_loggedIn)
            {
                LoginToDigg(username, password);
            }

            HttpWebRequest req            = CreateRequest(url, _cookies);
            string         responseString = GetResponseString(req);

            //parse out the stories...  I know, I know, the jedi should learn regex
            string[]         stories       = responseString.Split(new string[] { " target=\"_blank\">" }, StringSplitOptions.None);
            List <DiggStory> diggStoryList = new List <DiggStory>();
            int d = 0;

            for (int i = 1; i < stories.Length; i += 2)
            {
                DiggStory ds = new DiggStory();
                do
                {
                    ds.title = stories[i].Split('<')[0];
                    if (ds.title == "")
                    {
                        i++;
                    }
                } while (ds.title == "");
                string temp = stories[i + 1].Split(new string[] { "<p>" }, StringSplitOptions.None)[1];
                ds.description = temp.Substring(0, temp.IndexOf('&'));
                ds.diggUrl     = temp.Substring(temp.IndexOf("href=") + 6);
                ds.diggUrl     = ds.diggUrl.Substring(0, ds.diggUrl.IndexOf('"'));
                ds.url         = stories[i - 1].Substring(stories[i - 1].LastIndexOf("href=") + 6);
                ds.url         = ds.url.Substring(0, ds.url.Length - 1);
                string diggs = temp.Substring(0, temp.IndexOf("</strong>"));
                ds.diggs = diggs.Substring(diggs.LastIndexOf('>') + 1);
                string[] idInfoTemp = stories[i + 1].Split(new string[] { "javascript:wrapper_full(" }, StringSplitOptions.None);
                if (idInfoTemp.Length > 1)
                {
                    string idInfo = idInfoTemp[1];
                    idInfo = idInfo.Substring(0, idInfo.IndexOf(')'));
                    string[] infoDetails = idInfo.Split(',');
                    ds.id        = infoDetails[2];
                    ds.row       = infoDetails[0];
                    ds.diggCheck = infoDetails[3].Substring(1, infoDetails[3].Length - 2);
                }
                diggStoryList.Add(ds);
            }
            return(diggStoryList.ToArray());
        }