public static void Get()
{
// string xpathtrI = "//*[@id='classify-list']/dl/dd/a/cite/span/i";
#region 获取首页的分类 ////主页的html地址
//string urlHome = "http://www.qidian.com/";
//HtmlWeb web = new HtmlWeb();
//HtmlAgilityPack.HtmlDocument htmlDoc = web.Load(urlHome);
////创建html的节点
//HtmlNode rootNode1 = htmlDoc.DocumentNode;
//string xpathtrA = "//*[@id='classify-list']/dl/dd";
//HtmlNodeCollection classList = rootNode1.SelectNodes(xpathtrA);
//List<string> listINode = new List<string>();
//foreach (HtmlNode item in classList)
//{
// //获取分类
// string inode = item.SelectSingleNode("//a/cite/span/i").InnerText;
// listINode.Add(inode);
//} #endregion #region 分类及明细 //string urlDetail = "http://xuanhuan.qidian.com/";
//List<string> urlList = new List<string>();
//urlList.Add("http://xuanhuan.qidian.com/");
//urlList.Add("http://qihuan.qidian.com/");
//urlList.Add("http://wuxia.qidian.com/");
//urlList.Add("http://xianxia.qidian.com/");
//urlList.Add("http://dushi.qidian.com/");
//urlList.Add("http://zhichang.qidian.com/");
//urlList.Add("http://junshi.qidian.com/");
//urlList.Add("http://lishi.qidian.com/");
//urlList.Add("http://youxi.qidian.com/");
//urlList.Add("http://tiyu.qidian.com/");
//urlList.Add("http://kehuan.qidian.com/");
//urlList.Add("http://lingyi.qidian.com/");//foreach (string url in urlList)
//{
// HtmlAgilityPack.HtmlDocument htmlDetail = web.Load(url);
// HtmlNode rootNode2 = htmlDetail.DocumentNode;
// string a = "//*[@class='book-info']";
// HtmlNodeCollection classList2 = rootNode2.SelectNodes(a);
// List<string> listINode2 = new List<string>();
// foreach (HtmlNode item in classList2)
// {
// //获取分类
// string inode = item.InnerHtml;
// listINode2.Add(inode);
// }
//} #endregion #region 文章内容 HtmlWeb web = new HtmlWeb();
string u = "http://read.qidian.com/chapter/zOGI9RYmNdFhO--gcH8iFg2/h3iHSEH1cSpMs5iq0oQwLQ2";
HtmlAgilityPack.HtmlDocument htmlDocment = web.Load(u);
//创建html的节点
HtmlNode htmlNode = htmlDocment.DocumentNode;
string x = "//*[@class='read-content j_readContent']";
HtmlNode htmlNodeP = htmlNode.SelectSingleNode(x);
string htmlD = htmlNodeP.InnerText; #endregion }

只是拿一个例子而已。

C#使用xpath简单爬取网站的内容的更多相关文章

  1. Python入门,以及简单爬取网页文本内容

    最近痴迷于Python的逻辑控制,还有爬虫的一方面,原本的目标是拷贝老师上课时U盘的数据.后来发现基础知识掌握的并不是很牢固.便去借了一本Python基础和两本爬虫框架的书.便开始了自己的入坑之旅 言 ...

  2. Python简单爬取Amazon图片-其他网站相应修改链接和正则

    简单爬取Amazon图片信息 这是一个简单的模板,如果需要爬取其他网站图片信息,更改URL和正则表达式即可 1 import requests 2 import re 3 import os 4 de ...

  3. requests 使用免费的代理ip爬取网站

    import requests import queue import threading from lxml import etree #要爬取的URL url = "http://xxx ...

  4. Python 利用 BeautifulSoup 爬取网站获取新闻流

    0. 引言 介绍下 Python 用 Beautiful Soup 周期性爬取 xxx 网站获取新闻流: 图 1 项目介绍 1. 开发环境 Python: 3.6.3 BeautifulSoup:   ...

  5. Java - XPath解析爬取内容

    code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent; } pre { backg ...

  6. Golang+chromedp+goquery 简单爬取动态数据

    目录 Golang+chromedp+goquery 简单爬取动态数据 Golang的安装 下载golang软件 解压golang 配置golang 重新导入配置 chromedp框架的使用 实际的代 ...

  7. 使用scrapy爬取网站的商品数据

    目标是爬取网站http://www.muyingzhijia.com/上全部的商品数据信息,包括商品的一级类别,二级类别,商品title,品牌,价格. 搜索了一下,python的scrapy是一个不错 ...

  8. requests+xpath+map爬取百度贴吧

    # requests+xpath+map爬取百度贴吧 # 目标内容:跟帖用户名,跟帖内容,跟帖时间 # 分解: # requests获取网页 # xpath提取内容 # map实现多线程爬虫 impo ...

  9. 利用linux curl爬取网站数据

    看到一个看球网站的以下截图红色框数据,想爬取下来,通常爬取网站数据一般都会从java或者python爬取,但本人这两个都不会,只会shell脚本,于是硬着头皮试一下用shell爬取,方法很笨重,但旨在 ...

随机推荐

  1. Codeforces Round #443 (Div. 1) D. Magic Breeding 位运算

    D. Magic Breeding link http://codeforces.com/contest/878/problem/D description Nikita and Sasha play ...

  2. python正则表达式里引入变量

    import re def reg_exp(senten): jiqiren = "阿童木" matchObj1 = re.search( r'(你(.*?)(男|女))|(机器( ...

  3. virltualbox 升级之后 苹果虚拟机报The installed support driver doesn't match the version of the user解决方案

    1.反安装virtualbox后,不要重启 2.删除virtualbox的安装目录 3.进入%userprofile% 目录 (比如: C:\users\me) 删除 .VirtualBox Virt ...

  4. 【MVP时间】5节课助你破解物联网硬件接入难点

    视频播放链接:https://mvp.aliyun.com/topic/10?spm=5176.8961170.detail.18.31a3yK4zyK4zUc 1.会上网的鸡,有啥不一样? http ...

  5. 链接了dpdk的进程启动core在 Illegal instruction

    失败后的core栈像下面这样: Program terminated with signal SIGILL, Illegal instruction. # 0x00000000036a3fdd in ...

  6. 自然语言处理中的N-Gram模型

    N-Gram(有时也称为N元模型)是自然语言处理中一个非常重要的概念,通常在NLP中,人们基于一定的语料库,可以利用N-Gram来预计或者评估一个句子是否合理.另外一方面,N-Gram的另外一个作用是 ...

  7. securecrt8.1破解版安装与注册机的使用方法

    转自:https://blog.csdn.net/sun897827804/article/details/78532157?locationNum=9&fps=1 SecureCRT是一款用 ...

  8. nginx环境安装配置fail2ban屏蔽攻击ip

    安装 fail2ban   yum install -y epel-release yum install -y fail2ban 设置 Nginx 的访问日志格式 这个是设置 fail2ban 封禁 ...

  9. ld: library not found for -lstdc++.6

    ld: library not found for -lstdc++.6 Xcode10 删除 libstdc++.6.tbd libstdc++.6.0.9.tbd 用 libc++.tbd lib ...

  10. BTARN 接收消息流以3A7为例

     1.RNIFReceive.aspx 页接收来自发起方的传入消息. (如果发起方是BizTalk则类似于:http://localhost/BTARNApp/RNIFSend.aspx?TPUrl ...