示例#1
0
        static List <SingleLetter> getAllPublicLetters()
        {
            List <SingleLetter> letters  = new List <SingleLetter>();
            HtmlWeb             futureme = new HtmlWeb();

            for (int i = 0; i < 50; i += 10)
            {
                HtmlDocument       doc        = futureme.Load("https://www.futureme.org/letters/recently_delivered?offset=" + i.ToString());
                HtmlNode           letterNode = doc.DocumentNode.SelectSingleNode("//*[@class='mainLeft']");
                HtmlNodeCollection previews   = letterNode.SelectNodes(".//*[@class='letter_preview JQLetterBodyPreview']");
                foreach (HtmlNode n in previews)
                {
                    HtmlNode     titleNode   = n.SelectSingleNode(".//*[@class='bold emailSubject']");
                    HtmlNode     contentNode = n.SelectSingleNode("(.//*[@class='short'])");
                    string       title       = titleNode.InnerText;
                    string       link        = "/letter.aspx?link=" + titleNode.Attributes["href"].Value;
                    string       content     = contentNode.InnerText;
                    SingleLetter s           = new SingleLetter();
                    s.Title   = title;
                    s.Link    = link;
                    s.Content = content;
                    letters.Add(s);
                }
            }
            return(letters);
        }
示例#2
0
 static List<SingleLetter> getAllPublicLetters()
 {
     List<SingleLetter> letters = new List<SingleLetter>();
     HtmlWeb futureme = new HtmlWeb();
     for (int i = 0; i < 50; i += 10)
     {
         HtmlDocument doc = futureme.Load("https://www.futureme.org/letters/recently_delivered?offset=" + i.ToString());
         HtmlNode letterNode = doc.DocumentNode.SelectSingleNode("//*[@class='mainLeft']");
         HtmlNodeCollection previews = letterNode.SelectNodes(".//*[@class='letter_preview JQLetterBodyPreview']");
         foreach (HtmlNode n in previews)
         {
             HtmlNode titleNode = n.SelectSingleNode(".//*[@class='bold emailSubject']");
             HtmlNode contentNode = n.SelectSingleNode("(.//*[@class='short'])");
             string title = titleNode.InnerText;
             string link = "/letter.aspx?link=" + titleNode.Attributes["href"].Value;
             string content = contentNode.InnerText;
             SingleLetter s = new SingleLetter();
             s.Title = title;
             s.Link = link;
             s.Content = content;
             letters.Add(s);
         }
     }
     return letters;
 }
示例#3
0
        static SingleLetter getLetter(string s)
        {
            SingleLetter       letter     = new SingleLetter();
            HtmlWeb            futureme   = new HtmlWeb();
            HtmlDocument       doc        = futureme.Load("https://www.futureme.org" + s);
            HtmlNode           letterNode = doc.DocumentNode.SelectSingleNode("//*[@class='mainLeft']");
            HtmlNode           titleNode  = letterNode.SelectSingleNode("./h3");
            HtmlNodeCollection fullleter  = letterNode.SelectNodes(".//*[@class='letter']");
            string             content    = "";

            foreach (HtmlNode l in fullleter)
            {
                string st = l.InnerText;
                content = content + st + "<br/><br/>";
            }
            letter.Title   = titleNode.InnerText;
            letter.Content = content;
            return(letter);
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            checkTopbar();
            String s = Request.QueryString["link"];

            if (s == null)
            {
                return;
            }
            SingleLetter letter = getLetter(s);

            //panel 0

            Panel p = new Panel();

            p.Attributes.Add("class", "form-group");
            //label
            Label l = new Label();

            //l.Attributes.Add("runat", "server");
            l.Text = letter.Title;
            l.Attributes.Add("Class", "col-lg-2 control-label");
            l.ID        = "Label1";
            l.ForeColor = System.Drawing.Color.RoyalBlue;
            //labelText.
            //panel1
            Panel p1 = new Panel();

            p1.Attributes.Add("class", "col-lg-10");
            Literal text = new Literal();

            text.Text = letter.Content;
            text.Mode = LiteralMode.PassThrough;
            //add
            p.Controls.Add(l);
            p.Controls.Add(p1);
            p1.Controls.Add(text);
            letterContain.Controls.Add(p);
        }