C # webbrowser

Source: Internet
Author: User

I recently worked as an intern at the company. I had to get stuck every time I went to work. When I first arrived, I always forgot! But I had to write a timed entry into the company's OA card.Program! During the writing process, it was found that buttons (images and hyperlinks) on the company's OA system (website) were difficult to find. After analyzing the webpage source code, it was found that the company's OA system was deployed in frame layout, for precise positioning, I recursively traverse all the frames of the OA system andCodeAll are mined! To locate the elements you want to obtain!

// Webbrowser first sets the URL and then fills in the data (account and password) to automatically log on to Oa. After the website is loaded, the analysis framework starts.

// Here I put the Framework Structure on the Treeview tree control.

Private hashtable htframe = new hashtable (); // key: Framework name value: Framework object
Private hashtable htframecontent = new hashtable (); // key: Framework name value: HTML code in the framework

Private void button#click (Object sender, eventargs E)
{
Treeview1.nodes. Clear ();
Htframe. Clear ();
Htframecontent. Clear ();
Treeview1.nodes. Add ("frames"); // Root Node
Fillframe (treeview1.nodes [0], webbrowser1.document. Window. Frames); // call
}

// Traverse all frameworks
Private void fillframe (treenode TN, htmlwindowcollection HWC)
{
If (HWC = NULL) return;
Foreach (htmlwindow HW in HWC)
{
Treenode tmpnode = tn. nodes. Add (TN. Text + "--" + HW. Name); // prevent sub-frameworks in different frameworks from having the same name
Htframe. Add (tmpnode. Text, HW); // frame name and frame object
Htframecontent. Add (tmpnode. Text, HW. Document. Body. innerhtml); // framework name and HTML in the framework
If (HW. frames. Count> 0) fillframe (tmpnode, HW. Frames );
}
}

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.