Use vb.net to do a forum post software

Source: Internet
Author: User
Tags resource thread visual studio

Author: tuenhai.com msn:king#tuenhai.com

Copyright NOTICE: You can reprint, reprint, please be sure to hyperlink form to indicate the original source of the article and author information and this statement
http://www.Tuenhai.com/

Preface: If you often bubble a variety of forums to publish harangues upon, if you want to put your software in a very short period of time to submit to the relevant website, if you want to make your site quickly landing on the search engines, if you want to do a forum automatic posting software, this article may be helpful to you.

Development tools: Microsoft Visual Studio. NET 2003
Operating system: Windows XP

Automatic post-implementation without programming

Does not programming also can realize the forum automatic posting?
The answer is yes. October 2003 ago, Tuenhai has not yet learned programming (VB6), but Tuenhai has implemented the Forum automatic posting device. Although this method is not tuenhai now, it may be useful to some friends, or introduce the implementation method here.
Implementation of the principle is: to borrow analog keyboard, mouse operation software, grab the input frame coordinates, and then simulate moving the mouse to the specified coordinates, analog keyboard input characters, analog enter or click the appropriate position to complete the automatic posting. Of course, you have to write the corresponding automation script, although it is a little difficult, but for programming, it should be simple.
There are three analog keyboard, mouse class software, the function is better, in the VS. NET Learning Methodology "http://www.Tuenhai.com/has been introduced.
I. Pcworker (http://www.pcworker.net)
Pcworker has a lot of features, and more importantly, the scripting code in Pcworker is the code you can read:

Press VK_F1//simulation pressing F1 presses VK_CTRL+VK_F//Simulation Press CTRL + F keys

Is it not too hard?

Two. "Key Genie" (Http://www.vrbrothers.com/cn/qmacro)
Relatively speaking, the key wizard is easy to use, but only a small part of the Pcworker function. For example, Pcworker can output random number, the key wizard is not.
The scripting code for the Keystroke wizard is not easy to read, such as
KeyPress 82 1
Can you tell which button is pressed?

Three. Ezscript (http://ezscript.seed.cx/)
Ezscript also has a lot of functions. However, Tuenhai does not respond when you try to post automatic posts under Windows XP.

Beginners recommend the use of Key Wizard, advanced use Pcworker. Use the tutorial to refer to the author's website.


Use Axwebbrowser control to do forum automatic posting software

 
The Axwebbrowser control is the WebBrowser control in the VB6.
Use Axwebbrowser to do forum batch posting software, add the reference to Axwebbrowser control and mshtml first.
First navigate to the specified URL. Then wait for the page to load with the following code:

Do While brow. Busy
Application.doevents ()
Loop

Then call the post process.

Public Sub Fill ()
On Error Resume Next
Do While brow. Busy
Application.doevents ()
Loop

Dim Webdoc as Object = Brow. document.all
Dim Webtag as Object
Dim Lengthtag as Integer = webdoc.length-1

For Counttag as integer= 0 to Lengthtag
Webtag = Webdoc.item (Counttag)
Select Case Strings.lcase (Webdoc.item (Counttag). tagname)
Text boxes in the case "textarea" page
Select Case Webtag.name
Case "Body" "" Body "from the Web page source code, different sites are likely to be different, you according to the actual modification." Same
Webtag.value = Strbody ' This is a predefined value, hereinafter.
End Select

Drop-down selection box in case "select" Page
Select Case Webtag.name
Case "Month" Select month, here is slightly last year, day of choice, because the principle is the same.
WebTag.all.item (1). selected = True ' Select first value
End Select

The input box in the case "input" page
Select case Strings.lcase (Webtag.type)
Case "Text"
Select Case Webtag.name
Case "Name", "userid", "nickname" ' username
Webtag.value = StrName
Case "Subject" ' Title
Webtag.value = Strsubject
Case "Regid" ' Registration code
Webtag.value = Strregid
Case "username", "realname"
Webtag.value = strUserName
Case "Cardnumber"
Webtag.value = Strcardnumber
Case "HomePhone"
Webtag.value = Strhomephone ' Telephone number
Case "Url_title" ' Link name
Webtag.value = Urltitle
Case "url" link
Webtag.value = URL
Case "Email" email address
Webtag.value = Email
Case "img" Picture
Webtag.value = img
Case "MIDI" music
Webtag.value = MIDI
Case "Year"
Webtag.value = Stryear
Case "Prompt" ' Retrieve password hint question
Webtag.value = strprompt
Case "Answer" ' Retrieve password answer
Webtag.value = Stranswer
End Select
Case "password" ' Password
Select Case Webtag.name
Case "passwd", "Password", "Confirm", "repasswd" ' Password, confirm password
Webtag.value = Strpass
End Select
Case "checkbox" Radio Box
Select Case Webtag.name
Case "Emailme" ' Email notification Tuenhai
webtag.checked = True
End Select

End Select

End Select
Next

Brow. Document.forms (0). Submit () ' Many Web forms, this simple code that implements Autocommit

End Sub

So the main process is this:

Public Sub Autoadd ()
Brow. Silent = True ' does not eject window
Brow. Navigate ("http://www.Tuenhai.com") ' Tuenhai's station as an example
Do While FormBrowNetsh.brow.Busy ' waits for the webpage to load complete
Application.doevents ()
Loop
Call Fill ()
End Sub

The above code can realize the visual automatic registration and forum automatic posting tool.
There are still a few questions to be resolved:
First, some sites to fill in the number of identification code to register or speak, how to use the program to achieve automatic identification of the number of recognition code picture?
Two. Some web site will jump out of a welcome dialog box, the program's operation was suspended.
Three. For autoenrollment and speaking, loading slower pictures, Flash, music, etc. is not required.

  
Use the HttpWebRequest class to do forum quick posting device

Use the HttpWebRequest class to do forum posting machine is much simpler.
We can never forget that the best tutorial is MSDN, typing HttpWebRequest in Microsoft Visual Studio. NET 2003 "Search" (in fact, many tutorial books are copied from MSDN):
Namespaces: System.Net
The HttpWebRequest class provides support for the properties and methods defined in WebRequest, as well as additional properties and methods that enable users to interact directly with servers that use HTTP.
Do not use the HttpWebRequest constructor. Initializes a new instance of the HttpWebRequest using the WebRequest.Create method. If the scheme of the URI is http://or https://, Create returns the HttpWebRequest instance.
The GetResponse method issues a synchronization request to the Internet resource specified in the RequestUri property and returns the HttpWebResponse instance that contains the response. You can use the BeginGetResponse and EndGetResponse methods to issue asynchronous requests to Internet resources.
When you want to send data to an Internet resource, the GetRequestStream method returns the Stream instance used to send the data. The BeginGetRequestStream and EndGetRequestStream methods provide asynchronous access to the sent data stream.
If an error occurs while accessing the Internet resource, the HttpWebRequest class throws a WebException. The Webexception.status property is one of the WebExceptionStatus values that indicates the source of the error. When Webexception.status is WebExceptionStatus.ProtocolError, the Response property contains HttpWebResponse that is received from Internet resources.
  

Shared Sub PostData ()
Dim Httpurl as New System.Uri ("http://www.") Tuenhai.com? "&" Name=yourname&pass=yourpass&cardnumber=yourcardnumber ")
Dim req as HttpWebRequest
' Req. Timeout = 10000 ' Set timeout value 10 seconds
req = CType (WebRequest.Create (HTTPURL2), HttpWebRequest)
Req. method = "POST"
Req. ContentType = "application/x-www-form-urlencoded"
Dim Bytesdata () as Byte = System.Text.Encoding.ASCII.GetBytes ("" Name=yourname&pass=yourpass&cardnumber= Yourcardnumber ")
Req. ContentLength = Bytesdata.length
Dim Poststream as Stream = req. GetRequestStream ()
Poststream.write (bytesdata, 0, bytesdata.length) ' above to the server post information.

Dim res as HttpWebResponse = CType (req. GetResponse (), HttpWebResponse) ' below get server return information
Dim Reader as StreamReader = _
New StreamReader (Res. GetResponseStream, System.Text.Encoding.GetEncoding ("GB2312"))
Dim resphtml as String = reader. ReadToEnd ()
MsgBox (resphtml) ' This is the information returned after post to the network server
MsgBox (Res. statuscode.tostring) ' status code returned after post to the network server
Res. Close () ' Off

End Sub

Use Axwebbrowser control to do forum post machine left three problems, with the HttpWebRequest class to achieve, the latter two problems are no longer exist. Also, using the HttpWebRequest class to implement the forum post is much faster. But, the same?
Some sites to fill in the number of identification code to register or speak, how to use the "Forum Automatic posting Machine" to achieve the automatic recognition code image number?

We add threads in the main process, because we will use multithreading to do the automatic posting machine AH. Using multithreading to do forum automatic posting device in the VB6 is not easy to achieve in the vb.net, do automatic posting tools is not difficult.
 

Dim Threadadd as System.Threading.Thread ' defines a thread
Public Sub Threadautoadd ()
threadadd= New System.Threading.Thread (AddressOf postdata) ' Creates a thread instance
Threadnetsh.start () ' Start thread
' Don't forget to add Threadautoadd.abort () at the end of Sub PostData () to close the thread
' Or here Add the code that judges the sub PostData () and close the thread if it's finished
End Sub


Visual Studio. NET 2003 is a comprehensive development tool for building fast to Microsoft Windows? and the Web and connecting to Microsoft. NET applications, have you greatly improved our development efficiency?



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.