2012-03-04 38 views
0

我試圖通過C#在webforum中提交私人消息。 我可以在每個組件填充除了消息框本身:填寫VBulliten的文本私人消息

NK

設置textarea的的innerText元素的常用方法做什麼都沒有,它適用於網頁,但不是本其餘??我不知道爲什麼,我可以確認代碼正確識別此區域。 我只能想象別的東西真正控制了顯示和提交值。 我發現:

當我將值設置爲除0,該消息將發佈但每次文本丟失。

任何想法?

+0

*我終於想出解決辦法。因爲下面的內容被vbulliten阻止了,所以用了另一種方式。 我仍然使用網頁瀏覽器導航到網站的登錄頁面,但是隨後我得到它生成的cookie,並通過簡單的網頁請求傳遞詳細信息以複製表單的帖子。使用SmartSniff找到所需的信息。很有用。乾杯。 – 2012-04-25 10:45:16

回答

0

我不知道什麼是你最喜歡訪問網頁的方法,但你可以創建一個虛擬web瀏覽器的形式,然後用一個函數喜歡它:

void SetText(string attribute, string attName, string value) 
    { 
     HtmlElementCollection tagsCollection = webBrowser1.Document.GetElementsByTagName("input"); 

     foreach (HtmlElement currentTag in tagsCollection) 
     { 

      if (currentTag.GetAttribute(attribute).Equals(attName)) 
       currentTag.SetAttribute("value", value); 
     } 
    } 

    void CheckBox(string attribute, string attName, string value) 
    { 

     // Get a collection of all the tags with name "input"; 

     HtmlElementCollection tagsCollection = webBrowser1.Document.GetElementsByTagName("input"); 

     foreach (HtmlElement currentTag in tagsCollection) 
     { 
      if (currentTag.GetAttribute(attribute).Equals(attName)) 
       currentTag.SetAttribute("checked", value); 
     } 
    } 


    void ClickButton(string attribute, string attName) 
    { 
     webBrowser1.Document.GetElementsByTagName("input"); 
     HtmlElementCollection col = webBrowser1.Document.GetElementsByTagName("button"); 

     foreach (HtmlElement element in col) 
     { 
      if (element.GetAttribute(attribute).Equals(attName)) 
      { 
       element.InvokeMember("click"); 
      } 
     } 
    }