none
Html Agility Pack Javascript sayfa değiştirmek? RRS feed

  • Genel Tartışma

  • Öncelikle çekeceğim veri özel olduğu için adresi yazamadım kurusabakmayın. ilk sorunum sayfa çok geç yüklendiği için XPath hatası alıyorum sanırım ayrıca webbrowser kullanmadan login olabilirmiyim?

    ikinsi olarak yaklaşık 120 sayfayı gezmem gerekiyor ama sayfanın value değerini değişmeme rağmen sayfa kendini yenilemiyor bu konuda yardımcı olursanız çok sevinirim.

    <select name="SAYFA" size="1" id="SAYFA" onchange="document.form1.YAPILACAKIS.value='BUL'; document.form1.submit();">
    <option value="0">1</option>
    
    <option value="1">2</option>
    
    <option value="2">3</option>
    
    <option value="3">4</option>
    
    <option value="4">5</option>
    
    <option value="5">6</option>
    
    <option value="6">7</option>
    
    <option value="7">8</option>
    
    <option value="8">9</option>
    
    <option value="9">10</option>
    
    <option value="10">11</option>
    
    <option value="11">12</option>
    
    <option value="12">13</option>
    
    <option value="13">14</option>
    
    <option value="14">15</option>
    
    <option value="15">16</option>
    
    <option value="16">17</option>
    
    <option value="17">18</option>
    
    <option value="18">19</option>
    
    <option value="19">20</option>
    
    <option value="20">21</option>
    
    <option value="21">22</option>
    
    <option value="22">23</option>
    
    <option value="23">24</option>
    
    <option value="24">25</option>
    
    <option value="25">26</option>
    
    <option value="26">27</option>
    
    <option value="27">28</option>
    
    <option value="28">29</option>
    
    <option value="29">30</option>
    
    <option value="30">31</option>
    
    <option value="31">32</option>
    
    <option value="32">33</option>
    
    <option value="33">34</option>
    
    <option value="34">35</option>
    
    <option value="35">36</option>
    
    <option value="36">37</option>
    
    <option value="37">38</option>
    
    <option value="38">39</option>
    
    <option value="39">40</option>
    
    <option value="40">41</option>
    
    <option value="41">42</option>
    
    <option value="42">43</option>
    
    <option value="43">44</option>
    
    <option value="44">45</option>
    
    <option value="45">46</option>
    
    <option value="46">47</option>
    
    <option value="47">48</option>
    
    <option value="48">49</option>
    
    <option value="49">50</option>
    
    <option value="50">51</option>
    
    <option value="51">52</option>
    
    <option value="52">53</option>
    
    <option value="53">54</option>
    
    <option value="54">55</option>
    
    <option value="55">56</option>
    
    <option value="56">57</option>
    
    <option value="57">58</option>
    
    <option value="58">59</option>
    
    <option value="59">60</option>
    
    <option value="60">61</option>
    
    <option value="61">62</option>
    
    <option value="62">63</option>
    
    <option value="63">64</option>
    
    <option value="64">65</option>
    
    <option value="65">66</option>
    
    <option value="66">67</option>
    
    <option value="67">68</option>
    
    <option value="68">69</option>
    
    <option value="69">70</option>
    
    <option value="70">71</option>
    
    <option value="71">72</option>
    
    <option value="72">73</option>
    
    <option value="73">74</option>
    
    <option value="74">75</option>
    
    <option value="75">76</option>
    
    <option value="76">77</option>
    
    <option value="77">78</option>
    
    <option value="78">79</option>
    
    <option value="79">80</option>
    
    <option value="80">81</option>
    
    <option value="81">82</option>
    
    <option value="82">83</option>
    
    <option value="83">84</option>
    
    <option value="84">85</option>
    
    <option value="85">86</option>
    
    <option value="86">87</option>
    
    <option value="87">88</option>
    
    <option value="88">89</option>
    
    <option value="89">90</option>
    
    <option value="90">91</option>
    
    <option value="91">92</option>
    
    <option value="92">93</option>
    
    <option value="93">94</option>
    
    <option value="94">95</option>
    
    <option value="95">96</option>
    
    <option value="96">97</option>
    
    <option value="97">98</option>
    
    <option selected="selected" value="98">99</option>
    
    <option value="99">100</option>
    
    <option value="100">101</option>
    
    <option value="101">102</option>
    
    <option value="102">103</option>
    
    <option value="103">104</option>
    
    <option value="104">105</option>
    
    <option value="105">106</option>
    
    <option value="106">107</option>
    
    <option value="107">108</option>
    
    <option value="108">109</option>
    
    <option value="109">110</option>
    
    <option value="110">111</option>
    
    <option value="111">112</option>
    
    <option value="112">113</option>
    
    <option value="113">114</option>
    
    <option value="114">115</option>
    
    <option value="115">116</option>
    
    <option value="116">117</option>
    
    <option value="117">118</option>
    
    <option value="118">119</option>
    
    <option value="119">120</option>
    
    <option value="120">121</option>
    
    <option value="121">122</option>
    
    
    </select>

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using HtmlAgilityPack;
    using System.Net;
    using System.IO;
    
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public String html;
            public Uri url;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
    
                
                Verial("http://orneksite.com", "//*[@id='DETAYLAR']/table/tbody[2]/tr[9]/td[7]", listBox1);
                                                                                                 
    
    
            }
    
            public void Verial(String Url, String XPath, ListBox Cikansonuc)
    
            {
                try
                {
                    url = new Uri(Url);
                }
                catch (UriFormatException)
                {
    
                    if (MessageBox.Show("Hatalı url", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
                }
                catch (ArgumentNullException)
                {
    
                    if (MessageBox.Show("Hatalı url", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
                }
                WebClient client = new WebClient();
                client.Encoding = Encoding.UTF8;
                try
                {
                    html = client.DownloadString(url);
                }
                catch (WebException)
                {
    
                    if (MessageBox.Show("Hatalı url", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
                }
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument ();
                doc.LoadHtml(html);
                try
                {
                    Cikansonuc.Items.Add(doc.DocumentNode.SelectSingleNode(XPath).InnerText);
                }
                catch (NullReferenceException)
    
                {
    
                    if (MessageBox.Show("Hatalı XPath", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
    
                }
    
            }
    
    
    
            public void Verialdip(String Url, String XPath, String dip, ListBox Cikansonuc)
    
            {
                try
                {
                    url = new Uri(Url);
                }
                catch (UriFormatException)
                {
    
                    if (MessageBox.Show("Hatalı url", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
                }
                catch (ArgumentNullException)
                {
    
                    if (MessageBox.Show("Hatalı url", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
                }
                WebClient client = new WebClient();
                client.Encoding = Encoding.UTF8;
                try
                {
                    html = client.DownloadString(url);
                }
                catch (WebException)
                {
    
                    if (MessageBox.Show("Hatalı url", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
                }
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(html);
                try
                {
                    Cikansonuc.Items.Add(doc.DocumentNode.SelectSingleNode(XPath).Attributes[dip].Value);
                }
                catch (NullReferenceException)
    
                {
    
                    if (MessageBox.Show("Hatalı XPath", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                    {
    
                    }
    
                }
    
            }
            string id = "969656";
            string kadi= "Fatih";
            string sifre = "12345678";
    
            private void button2_Click(object sender, EventArgs e)
            {
                //HtmlElement eleman;
                webBrowser1.Document.GetElementById("kulno").InnerText = id;
                webBrowser1.Document.GetElementById("kuladi").InnerText = kadi;
                webBrowser1.Document.GetElementById("kulsifre").InnerText = sifre;           
                webBrowser1.Document.GetElementById("btngiris").InvokeMember("CLICK");         
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
    
                webBrowser1.Navigate("http://orneksite.com");
                while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents(); 
                }
    
                
            }
    
            private void button4_Click(object sender, EventArgs e)
            {
                foreach (HtmlElement olayn in webBrowser1.Document.GetElementsByTagName("select"))
                {
                    if (olayn.GetAttribute("name") == "SAYFA")
                    {
                        olayn.SetAttribute("value", "88");
                       
    
                    }
                }
    
    
            }
        }
    }
    

    18 Ağustos 2018 Cumartesi 15:27