批量读取网页中的内容

                    //序号
                    index = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("b")[0].InnerHtml;
                    //题目
                    title = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("td")[0].InnerHtml.Split('.')[1];
                    ntr++;
                    //A项
                    A = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("td")[1].InnerHtml;
                    //图片
                    try
                    {
                        imageURL = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("img")[0].GetAttribute("src");
                        imageURL = imageURL.Substring(imageURL.LastIndexOf('/') + 1);
                        textBox1.Text = imageURL;
                    }
                    catch
                    {
                        imageURL = "";
                    }                   
                    ntr++;
                    //B项
                    B = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("td")[1].InnerHtml;
                    ntr++;
                    //C项
                    C = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("td")[1].InnerHtml;
                    ntr++;
                    //D项
                    D = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("td")[1].InnerHtml;
                    ntr++;
                    //答案
                    key = webBrowser1.Document.Body.GetElementsByTagName("tr")[ntr].GetElementsByTagName("td")[1].GetElementsByTagName("font")[0].InnerHtml[6].ToString();
                    ntr++;
                    string temp = " INSERT INTO Exam"+
                                  " ([index], title, A, B, C, D, type, [key], imageURL)"+
                                  " VALUES ({0}, '{1}', '{2}', '{3}', '{4}', '{5}', 'only4', '{6}', '{7}')";
                    string[] args = new string[8] { index, title, A, B, C, D, key, imageURL };
                    sb.AppendLine(string.Format(temp, args) + "@");

转载于:https://www.cnblogs.com/raymond19840709/archive/2007/12/11/990992.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值