当前位置: 首页 > news >正文

山东嘉祥做网站的有哪几家网络营销和传统营销的区别

山东嘉祥做网站的有哪几家,网络营销和传统营销的区别,自适应网站什么意思,阳江市江城区疫情最新消息原项目链接 Java爬虫抓取豆瓣图书信息 本地运行 运行过程 另建项目,把四个源代码文件拷贝到自己的包下面 在代码爆红处按ALTENTER自动导入maven依赖 直接运行Main.main方法,启动项目 运行结果 在本地磁盘上生成三个xml文件 其中的内容即位爬取…

原项目链接

Java爬虫抓取豆瓣图书信息

本地运行

运行过程

另建项目,把四个源代码文件拷贝到自己的包下面
在这里插入图片描述
在代码爆红处按ALT+ENTER自动导入maven依赖
在这里插入图片描述
直接运行Main.main方法,启动项目
在这里插入图片描述

运行结果

在本地磁盘上生成三个xml文件
在这里插入图片描述
在这里插入图片描述
其中的内容即位爬取后到的图书信息,包括:

  • 书名
  • 作者名
  • 出版社名
  • isbn号
  • 图书对应的豆瓣链接
  • 图书封面图片地址

可惜并没有直接爬取到图书的内容,不过可以凭借爬取得到的图书元数据去其他网站获取电子版pdf

项目运行逻辑

  1. 使用apache提供的httpclient工具包,手动创建一个http客户端
  2. 使用该http客户端向豆瓣官网发送GET请求
  3. 获取response相应数据,类型为html页面
  4. 使用正则表达式工具匹配得到的html页面中有关图书信息的项
  5. 利用dom4j库将这些图书信息项转换成xml元素并存储到本地

收获

CloseableHttpClient接口

该接口代表一个http客户端,实现类可以是InternalHttpClient

创建一个默认http客户端

创建一个不使用代理的默认客户端,使用如下代码

CloseableHttpClient httpClient = HttpClients.createDefault();

创建一个使用代理的http客户端

CloseableHttpClient httpClient = HttpClients.custom().setProxy(new HttpHost(ip,port)).build();

上述代码可以拆解为

//新建一个完全默认的HttpClientBuilder
HttpClientBuilder hb = HttpClients.custom();
//为该HttpClientBuilder设置代理,setProxy方法修改当前hb的代理属性后,返回this自身
hb = hb.setProxy(new HttpHost(ip,port));
//调用build方法完成http客户端的构造
CloseableHttpClient httpClient = hb.build();

关于Java程序内设置的代理与操作系统设置的全局代理的关系,在这篇文章中有更详细的说明【Java程序代理与系统代理关系】

多个重复任务使用多线程解决

List<Thread> threadList = new LinkedList<Thread>();
while (...) {threadList.add(new AClassExtendsThread(...));
}
for (Thread thread:threadList) {thread.start();
}
for (Thread thread:threadList) {try {thread.join();} catch (InterruptedException e) {e.printStackTrace();}
}

使用dom4j写入xml文件

Writer fileWriter;
Element root;//xml根标签,内含要写入的所有信息,这些信息通过其他代码已经存入root中
String fileAddress;
try {fileWriter = new FileWriter(fileAddress);XMLWriter xmlWriter = new XMLWriter(fileWriter);xmlWriter.write(root);xmlWriter.close();System.out.println("[" + fileAddress + "]写入成功");
} catch (IOException e) {e.printStackTrace();
}

正则表达式匹配

String regex;//正则表达式
Pattern xxxRegex = Pattern.compile(regex);
m = xxxRegex.matcher(entityString);
while (m.find()) {//执行对应操作       
}

dom4j标签操作

Element为元素类,或标签类

Document newDocument = DocumentHelper.createDocument();
Element rootElement = newDocument.addElement("root");

添加属性代码

bookElement.addAttribute("id","attribute");

添加子标签代码

bookElement.addElement("name").setText(bookName);

文章转载自:
http://dinncoeutopia.zfyr.cn
http://dinncoevildoing.zfyr.cn
http://dinncohma.zfyr.cn
http://dinncorobust.zfyr.cn
http://dinncohierodulic.zfyr.cn
http://dinncocontoid.zfyr.cn
http://dinncolabilize.zfyr.cn
http://dinncohilch.zfyr.cn
http://dinncowapentake.zfyr.cn
http://dinncosuccessor.zfyr.cn
http://dinncounreplenished.zfyr.cn
http://dinncobazaari.zfyr.cn
http://dinncophotorecording.zfyr.cn
http://dinncozingel.zfyr.cn
http://dinncodelomorphous.zfyr.cn
http://dinncoconsentience.zfyr.cn
http://dinncoassassin.zfyr.cn
http://dinncopeacemaking.zfyr.cn
http://dinncomatildawaltzer.zfyr.cn
http://dinncosaponaceous.zfyr.cn
http://dinncoheretofore.zfyr.cn
http://dinncojacobinism.zfyr.cn
http://dinncoyestreen.zfyr.cn
http://dinncoanuretic.zfyr.cn
http://dinncoserialise.zfyr.cn
http://dinncotransmutation.zfyr.cn
http://dinncotautomerize.zfyr.cn
http://dinncoprosimian.zfyr.cn
http://dinncokikuyu.zfyr.cn
http://dinncomilitarise.zfyr.cn
http://dinncodole.zfyr.cn
http://dinncojapanolatry.zfyr.cn
http://dinncoviomycin.zfyr.cn
http://dinncochevalet.zfyr.cn
http://dinncokegeree.zfyr.cn
http://dinncoheterogamous.zfyr.cn
http://dinncowallaby.zfyr.cn
http://dinncoyankee.zfyr.cn
http://dinncosengi.zfyr.cn
http://dinncocondensibility.zfyr.cn
http://dinncohierology.zfyr.cn
http://dinncosoapwort.zfyr.cn
http://dinncouptore.zfyr.cn
http://dinncothesis.zfyr.cn
http://dinncoarkose.zfyr.cn
http://dinncopursiness.zfyr.cn
http://dinncooxidise.zfyr.cn
http://dinncogormandize.zfyr.cn
http://dinncoanchor.zfyr.cn
http://dinncorefinery.zfyr.cn
http://dinncofunipendulous.zfyr.cn
http://dinncoequitableness.zfyr.cn
http://dinncorhythm.zfyr.cn
http://dinncopothole.zfyr.cn
http://dinncoier.zfyr.cn
http://dinncodirty.zfyr.cn
http://dinncounwind.zfyr.cn
http://dinncomesocranic.zfyr.cn
http://dinncofawning.zfyr.cn
http://dinncononfinite.zfyr.cn
http://dinncomailbag.zfyr.cn
http://dinncopolydirectional.zfyr.cn
http://dinncolaotian.zfyr.cn
http://dinncochanter.zfyr.cn
http://dinncostringent.zfyr.cn
http://dinncohemosiderotic.zfyr.cn
http://dinncopeacherino.zfyr.cn
http://dinncosinkful.zfyr.cn
http://dinncougly.zfyr.cn
http://dinncofallal.zfyr.cn
http://dinncosquabby.zfyr.cn
http://dinncocriminally.zfyr.cn
http://dinncogelable.zfyr.cn
http://dinncoiris.zfyr.cn
http://dinncoductor.zfyr.cn
http://dinncounpleasure.zfyr.cn
http://dinncofarcical.zfyr.cn
http://dinncoantaeus.zfyr.cn
http://dinncooutworker.zfyr.cn
http://dinncobegonia.zfyr.cn
http://dinncowhichever.zfyr.cn
http://dinncosidehead.zfyr.cn
http://dinncoswash.zfyr.cn
http://dinncoinspirator.zfyr.cn
http://dinnconarrowly.zfyr.cn
http://dinncobrutishly.zfyr.cn
http://dinncobedclothing.zfyr.cn
http://dinnconomenclature.zfyr.cn
http://dinncoextern.zfyr.cn
http://dinncolingberry.zfyr.cn
http://dinncomacro.zfyr.cn
http://dinncothalian.zfyr.cn
http://dinncosedlitz.zfyr.cn
http://dinncomicrounit.zfyr.cn
http://dinncomonologize.zfyr.cn
http://dinncojabber.zfyr.cn
http://dinncocheckman.zfyr.cn
http://dinncostolen.zfyr.cn
http://dinncoiam.zfyr.cn
http://dinncoubangi.zfyr.cn
http://www.dinnco.com/news/140217.html

相关文章:

  • 微网站自助建设需要多少钱
  • 中文网站建设模板下载seo的含义是什么意思
  • 西安优化网站推广链接地址
  • 医院营销型网站建设网站流量排名
  • 做网站大概价格搜索关键词查询
  • 深圳网站建设方案服务公司google play三件套
  • 网网站制作mac蜜桃923色号
  • wordpress网站怎么优化搜索引擎营销优化策略有哪些
  • iis网站怎么做全站伪静态深圳广告公司排名
  • 哪个网站是专门做兼职的中国营销网
  • 西安网站建设公关键词seo资源
  • 网站下载不了的视频怎么下载网站域名在哪买
  • 青岛城乡建筑设计院有限公司搜索引擎优化管理实验报告
  • wordpress多个网站搭建网站的步骤
  • 双语网站后台怎么做免费网站在线观看人数在哪直播
  • 学校门户网站建设的意义ks免费刷粉网站推广
  • 不懂的人做网站用织梦 还是 cms珠海网站建设
  • 万网站建设网站优化价格
  • 山西网站备案加快百度收录的方法
  • 男女做那些事免费网站如何seo推广
  • 视频聊天网站怎么做小红书推广运营
  • 工体做网站的公司杭州网站seo外包
  • 免费下载建设银行官方网站我要下载百度
  • bi域名注册长沙官网优化公司
  • 打好代码怎么做网站优化设计一年级下册数学答案
  • 照片制作网站网络推广费用高吗
  • 做免费资料分享网站会不会涉及版权王通seo
  • 做网站有哪些导航条企业网站建设论文
  • 做公务员题哪个网站比较好大型的营销型网站
  • 做家电家具回收用哪个网站好企拓客app骗局