在学习C#的阶段中,我们一点一点的往前爬,
此代码需要添加selenium ,和 获取 引用。
using Ivony.Html.Parser;
using Ivony.Html;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace taobao
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static Thread th;
private void button1_Click(object sender, EventArgs e)
{
th = new Thread(new ThreadStart(JDData));
th.Start();
}
void JDData()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://list.jd.com/list.html?cat=9987%2C653%2C655&go=0");
//driver.FindElement(By.Id("startShopping")).Click();
//Thread.Sleep(5000);
//IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;
//int height = 1000;
//jse.ExecuteScript("document.documentElement.scrollTop=" + height);
//Thread.Sleep(20000);
string sc = driver.PageSource;
//以上步骤是获取网页源码
//var documentsc = new Jumon
var documenthtmlThree = new JumonyParser().Parse(sc);
driver.Quit();
}
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章