您的位置:首页 > 其它

批量读取网页中的内容

2007-12-11 16:51 274 查看
//序号

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) + "@");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: