各位大神,请问一下每秒访问一次URL的有关问题
各位大神,请教一下每秒访问一次URL的问题
每秒访问一次url,有时候会出现少一秒的情况,请问怎么解决。
public static void main(String[] args) throws InterruptedException {
Test tt=new Test();
tt.test();
}
public void test() throws InterruptedException{
String ss;
SimpleDateFormat df2;
Document doc = null;
while (true) {
df2 = new SimpleDateFormat("ss");
ss=df2.format(new Date());
String url = "http://www.baidu.com";
try {
doc = Jsoup.connect(url).get();//打开连接
} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println("时间:::"+ss+"内容:::"+doc.text());//获取秒数和页面内容
Thread.sleep(1000);
}
}
------解决思路----------------------
有没有考虑读取数据超过一秒。
------解决思路----------------------
不知道是不是1秒后就不需要读取。
你看看这个。
------解决思路----------------------
是否需要延后
每秒访问一次url,有时候会出现少一秒的情况,请问怎么解决。
public static void main(String[] args) throws InterruptedException {
Test tt=new Test();
tt.test();
}
public void test() throws InterruptedException{
String ss;
SimpleDateFormat df2;
Document doc = null;
while (true) {
df2 = new SimpleDateFormat("ss");
ss=df2.format(new Date());
String url = "http://www.baidu.com";
try {
doc = Jsoup.connect(url).get();//打开连接
} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println("时间:::"+ss+"内容:::"+doc.text());//获取秒数和页面内容
Thread.sleep(1000);
}
}
------解决思路----------------------
有没有考虑读取数据超过一秒。
------解决思路----------------------
不知道是不是1秒后就不需要读取。
你看看这个。
------解决思路----------------------
是否需要延后