Winform下HtmlElementCollection网页数据采集问题,求大神帮忙!

Winform下HtmlElementCollection网页数据采集问题,求大神帮忙!,第1张

你是否只采集表格甲的数据 如果是 首先你去看看你要采集的那个table有没有唯一的固定标示 比如说ID 要是有的话直接根据ID找table 如果没有 你首先遍历找到所有table 根据位置取出你要采集的table ; 比如说tables是你获取的所有table你就根据位置去敬渗指取到目标table ;如 var table=tables[1] ;亮配取出table中所有tr 再去取td 如果每行的td数量不一样 你就像楼上说的那样去做了 先喊滚判断是否存在如if(tds.count>=1){ dr[0]=tds[0].innerTex} else if(tds.count>=2){ dr[0]=tds[1].innerTex}

你有个误解,C#是不能 *** 作内存的,所以不存在内存变量这个说法。

如果你意思是static变量,那么明确告诉你,不会有影响的。

开了3个拆御程序,实际上是开了三个进程,注意,进程是对 *** 作系统负责(线程是对本程序负责),彼此间不通讯,所以只要你没有额外运御颤编写进程间通讯,那么就不会有旁败影响。

给你一个例子

private void button1_Click(object sender, EventArgs e)

{

chart1.DataSource = GetData()

// Set series members names for the X and Y values

chart1.Series["Series1"].XValueMember = "Time"

chart1.Series["Series1"].YValueMembers = "City"

chart1.Series["Series2"].XValueMember = "Time"

chart1.Series["Series2"].YValueMembers = "Count"

// Data bind to the selected data source

chart1.DataBind()

// Set series chart type

chart1.Series["Series1"].ChartType = SeriesChartType.Line

chart1.Series["Series2"].ChartType = SeriesChartType.Spline

// Set point labels

chart1.Series["Series1"].IsValueShownAsLabel = true

chart1.Series["Series2"].IsValueShownAsLabel = true

// Enable X axis margin

chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true

// Enable 3D, and show data point marker lines

//李型chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true

chart1.Series["Series1"]["ShowMarkerLines"] = "True"

chart1.Series["Series2"]["ShowMarkerLines"] = "True"

}

private DataTable GetData()

{

DataTable tableInfo = new DataTable()

DataColumn dctime = new DataColumn("Time", Type.GetType("System.String"))

DataColumn dcCity = new DataColumn("City", Type.GetType("System.String"))

DataColumn dcCount = new DataColumn("Count", Type.GetType("System.Int32"))

tableInfo.Columns.Add(dctime)

tableInfo.Columns.Add(dcCity)

tableInfo.Columns.Add(dcCount)

DataRow dr = tableInfo.NewRow()

dr["Time"] = "1:00"

dr["City"] = "10"

dr["Count"] = "15"

tableInfo.Rows.Add(dr)

DataRow dr1 = tableInfo.NewRow()

dr1["Time"] = "2:00"

dr1["City"] = "12"并枯

dr1["Count"] = "19"

tableInfo.Rows.Add(dr1)

DataRow dr2 = tableInfo.NewRow()

dr2["Time"] = "3:00"

dr2["City"] = "13"

dr2["哪蔽猜Count"] = "25"

tableInfo.Rows.Add(dr2)

DataRow dr3 = tableInfo.NewRow()

dr3["Time"] = "4:00"

dr3["City"] = "14"

dr3["Count"] = "10"

tableInfo.Rows.Add(dr3)

DataRow dr4 = tableInfo.NewRow()

dr4["Time"] = "5:00"

dr4["City"] = "15"

dr4["Count"] = "11"

tableInfo.Rows.Add(dr4)

DataRow dr5 = tableInfo.NewRow()

dr5["Time"] = "6:00"

dr5["City"] = "16"

dr5["Count"] = "17"

tableInfo.Rows.Add(dr5)

DataRow dr6 = tableInfo.NewRow()

dr6["Time"] = "7:00"

dr6["City"] = "17"

dr6["Count"] = "20"

tableInfo.Rows.Add(dr6)

DataRow dr7 = tableInfo.NewRow()

dr7["Time"] = "8:00"

dr7["City"] = "12"

dr7["Count"] = "13"

tableInfo.Rows.Add(dr7)

return tableInfo

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12259933.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存