This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java File类文件类 | |
File在java表示文件或文件夹(目录) | |
下面是如何用File来创建文件夹 | |
public class Test | |
{ | |
public static void main(String[] args) | |
{ | |
//1.创建目录 直接在磁盘目录下 | |
// File file = new File("c:/caozheng "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
爬虫数据的代码前面有,但是在爬取数据时注意要lists.clear();(清理数据) | |
还有要注意爬取信息的格式 | |
String title = e.select(".info h3 a").text(); | |
爬取数据标题是test格式 | |
String flag = e.select(".info h3 a").attr("href"); | |
爬取数据连接,在这里要注意数据是否完整,能否直接点击获取,有些链接有安全措施要注意。在这里的爬取小说的链接就是有缺陷的,我们要人为补充数据 | |
String author = e.select(".d1").text(); | |
String imgurl = e.select(".fl img").attr("src"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
学习Java一段时间后,我们可以通过实列来展示Java语言的魅力,下面是我通过爬取大众点评来展示 | |
在爬虫时要注意爬取的位置的抓取点 有id用#表示,class用 . 来表示。 | |
还有当遇见有反爬虫机制时我们应改这样 | |
 | |
{ | |
//int a=10; | |
Object obj = new Object(); | |
UserThread ut = new UserThread(obj); | |
ut.start(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java的多线程执行是无序的由JVM随机操控,但是我们可以通过synchronized方法或者synchronized同步块,使线程的安全性提高。(**注意**:synchronized 安全锁的对象只能作用于一个,不然锁不住) | |
如我们通过银行卡,微信,支付宝,同时对一个账户进行存取钱的操作。账户是对象,银行卡,微信,支付宝是三个线程 | |
三个线程随机开始进入 | |
synchronized (this) | |
{ System.out.println(Thread.currentThread().getName()+",欢迎来到工商银行!!"); | |
this.money+=opmoney; System.out.println(Thread.currentThread().getName()+ | |
",操作的金额为:"+opmoney+","+"现在账户的金额为:"+this.money); | |
System.out.println(Thread.currentThread().getName()+",谢谢你的操作,银行阶乘为你服务!!"); | |
} | |
三个线程操作数据 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
微信小程序通过ngrok服务和语法糖来和python进行数据连接 | |
wx.request({ | |
url: 'http://cz.free.idcfengye.com/login', | |
data: { "uname": this.data.namevalue, "upwd": this.data.pwdvalue }, | |
success: (resp) => { | |
var flag = resp.data | |
console.log(flag); | |
if (flag == "成功") { | |
//跳转页面 |