MainForm.cs
author StephaneLenclud
Thu, 14 May 2015 22:43:17 +0200
changeset 0 1d4344872495
child 1 f203331a8f4a
permissions -rw-r--r--
First drop.
Basic Sky Deutschland package frequency parssing.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 using CsQuery;
    11 using System.Diagnostics;
    12 using System.Net;
    13 
    14 
    15 
    16 namespace SatChanGen
    17 {
    18     public partial class MainForm : Form
    19     {
    20         public MainForm()
    21         {
    22             InitializeComponent();
    23         }
    24 
    25         private void buttonGenerate_Click(object sender, EventArgs e)
    26         {
    27 
    28             string kos = new WebClient().DownloadString("http://en.kingofsat.net/pack-skygermany.php");
    29             //Debug.Write(kos);
    30 
    31             CQ dom = kos;
    32 
    33 			//Get all the Frequency elements in our page
    34             CQ sats = dom[".frq"];
    35 
    36             foreach (IDomObject frq in sats.ToList())
    37             {
    38 	            Debug.Write("=====================\n");
    39 	            Channel common=new Channel();
    40 
    41 				//Parse channel details
    42 	            common.OrbitalPosition = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td > a > font").Get(0).InnerText);
    43 				common.Satellite = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(2) > a").Get(0).InnerText);
    44 				common.Frequency = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(3)").Get(0).InnerText);
    45 				common.Polarisation = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(4)").Get(0).InnerText);
    46 				common.Transponder = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(5) > a").Get(0).InnerText);
    47 				common.Beam = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(6) > a").Get(0).InnerText);
    48 				common.Standard = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(7)").Get(0).InnerText);
    49 				common.Modulation = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(8)").Get(0).InnerText);
    50 				common.SymbolRate = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(9) > a").Get(0).InnerText);
    51 				common.FEC = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(9) > a:nth-child(2)").Get(0).InnerText);
    52 	            try
    53 	            {
    54 					common.Provider = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(10) > b").Get(0).InnerText);
    55 	            }
    56 	            catch (Exception)
    57 	            {			
    58 	            }
    59 
    60 				common.Bitrate = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(10)").Get(0).InnerText);
    61 	            if (common.Bitrate.Substring(0, ", ".Length) == ", ")
    62 	            {
    63 					common.Bitrate = common.Bitrate.Substring(", ".Length, common.Bitrate.Length - ", ".Length);
    64 	            }
    65 				//
    66 				common.NetworkID = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(11)").Get(0).InnerText);
    67 				common.NetworkID = common.NetworkID.Substring("NID:".Length, common.NetworkID.Length - "NID:".Length);
    68 				//
    69 				common.TransponderID = WebUtility.HtmlDecode(frq.Cq().Find("tbody > tr > td:nth-child(12)").Get(0).InnerText);
    70 				common.TransponderID = common.TransponderID.Substring("TID:".Length, common.TransponderID.Length - "TID:".Length);
    71 
    72 				//Now get all the channels for that frequency
    73 				//Channel common = new Channel();
    74 
    75 								
    76 				Debug.Write(common.ToString());
    77 
    78             }
    79 
    80             //Debug.Write(sats.Text());
    81 
    82             /*
    83             CQ dom = "<div>Hello world! <b>I am feeling bold!</b> What about <b>you?</b></div>";
    84 
    85 
    86             CQ bold = dom["b"];               /// find all "b" nodes (there are two in this example)
    87 
    88             
    89   //> bold.ToList()
    90   //> Count = 2
    91   //> [0]: {<b>...</b>}
    92   //> [1]: {<b>...</b>}
    93 
    94   //> bold.First().RenderSelection()
    95   //> "<b>I am feeling bold!</b>"
    96             
    97             string boldText = bold.Text();        /// jQuery text method;
    98 
    99   //> boldText
   100   //> "I am feeling bold! you?"
   101 
   102             bold.Remove();                        /// jQuery Remove method
   103 
   104             string html = dom.Render();
   105 
   106             Debug.Write(html);
   107             */
   108         }
   109     }
   110 }