批量读取网页中的内容
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) + "@");
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) + "@");
相关文章推荐
- 利用chrome插件批量读取浏览器页面内容并写入数据库
- C#读取网页中的内容
- java用正则表达式分析读取网页内容(1)
- Java Web乱码-->读取网页中的数据(如输入框中的内容)写到数据库中乱码
- 读取网页内容
- iPhone读取网页内容乱码解决方案
- 读取网页的内容
- yii2从excel文件中读取表格内容,并批量写入数据库
- Python读取网页内容的方法
- 读取网页内容
- VB使用WebBrowser读取网页内容
- 批量采集上百万网页内容-php采集网页-php爬虫视频教程6
- 读取 抓取 网页内容
- Java读取网页内容并生成静态页面的简单实现
- java下载网页并读取内容
- java用正则表达式分析读取网页内容(2)
- AJAX实现简单的读取文本文档内容到网页--AJAX
- 读取Excel的内容,实现数据批量上传(转)
- 读取html网页文件内容
- win32+QT 实现exe中执行返回的网页内容重定向到txt文件,根据需求读取里面内容