2012-03-04 109 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"); 
      } 
     } 
    }