[formerly] An experiment using WebBrowser components to simulate the search results automatically by manually running search engines

Source: Internet
Author: User

This code is only idle time boring write to try, with the WebBrowser component simulation manual run search engine automatically click on the results of the experiment

This is a network of rumors to improve the search engine click-through rate of a way, of course, is cheating, not recommended you use. In addition, the performance of this method is poor, often because of the network and local machine for the reason of the halfway machine. Of course, if you just write this game, that's okay. Here is just one of the principles, there are many ways. If this method continues to optimize the detailed write down, you may need to refer to the VPN timing to change the IP address to the problem, of course, now even the VPN has a way to reverse find the original IP address.

The code examples are as follows:

usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingsystem.web;
usingSystem.Threading;

namespaceWinapp_huashanlin
{
Public Partial classFormhits:form
{
PublicFormhits ()
{
InitializeComponent ();
Webbrowser_huashanlin. Navigate ("http://www.baidu.com",false);
}


Private voidbutton2_click (Objectsender, EventArgs e)
{
//set the keywords to search
            stringHuashanlin_keys= "C #";

//choose Baidu Search as an experimental example, will webbrowser navigation to Baidu search home
Webbrowser_huashanlin. Navigate ("http://www.baidu.com", false);

//3 seconds to simulate manual viewing or input of keywords
Thread.Sleep ( the);

//Locate the input tag for the keyword entered in the page
HtmlElement key0s=Webbrowser_huashanlin. document.all["kw"];

//enter value for input tag
key0s. SetAttribute ("value", Huashanlin_keys);

//Find the button on the page or the submit button
HtmlElement Hit=Webbrowser_huashanlin. document.all["su"];

//Click event that triggers the search button
Hit . InvokeMember ("Click");

//It takes 3 seconds for the simulator to view the search results.
Thread.Sleep (9000);

//set the URL address that you want to find in the search results
            stringURL= "http://baike.baidu.com/view/6590.htm";

//encode URLs that need to be looked up
            stringEncodurl=System.Web.HttpUtility.UrlDecode (URL, System.Text.Encoding.Unicode);


BOOLIsget= false;

//matches the href attribute of all labels in the page as a hyperlink, if matched to the Click event that triggers the hyperlink
             for (intI= 0; I<Webbrowser_huashanlin. Document.All.Count; I++)
{
if(Webbrowser_huashanlin. Document.all[i]. Tagname.tostring (). Trim ()== "A")
{
stringTmpeurl=Webbrowser_huashanlin. Document.all[i]. GetAttribute ("href"). ToString ();
Tmpeurl=System.Web.HttpUtility.UrlDecode (Tmpeurl, System.Text.Encoding.Unicode);
if(Tmpeurl==Encodurl)
{
Isget= true;
//Webbrowserhuashanlin.document.all[i]. SetAttribute ("Target", "_self");//Open the page in the same Webbrowserhuashanlin browser component for easy follow-up.
Webbrowser_huashanlin. Document.all[i]. InvokeMember ("Click");//automatically click on the page you have set
                         Break;
}
}
}

if (!isget)
{
//If the URL is not found on the first page of the Baidu search results, find a hyperlink to the next page in the page and trigger the Click event.
//repeat the above steps in the next 10 search results to continue the search for matches, where you can sort the code into a recursive function loop until the target location is found.
//setting a wait time between each operation simulates the time of artificial waiting, and also leaves a buffer for possible network conditions
//The above is only a simple match to the URL set, the actual use of the need to further write a matching method, such as regular validation and so on
            }
}

}
}

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.