C # code Gets or sets the HTML in the IFRAME

Source: Internet
Author: User

In the recent data collection research, found that many of the content of the page is in the IFRAME, this collection has brought a lot of difficulties. After some thought, I thought of the C # solution:

1. Run spider Studio, load page http://www.w3school.com.cn/tiy/t.asp?f=html_iframe

2. Edit code to point iframe to http://www.w3school.com.cn

3. This page has the following structure:

Page > IFrame1-> IFrame2 (the IFRAME that we wrote in our code)

My goal is through C # code to get IFrame1 content, and then continue to get IFrame2 content, and then set IFrame2 src to GDT home.

4. Get IFrame1

var iframe1 = Default.selectsinglenode ("#result iframe"). Contents (). selectSingleNode ("body");
if (iframe1. IsEmpty () = = False)
{
    MessageBox.Show (iframe1). Html ());

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.