ugg

简介:

[html] view plain copy

print?
  1. import java.io.BufferedReader;
  2. import java.io.BufferedWriter;
  3. import java.io.File;
  4. import java.io.FileReader;
  5. import java.io.FileWriter;
  6. import java.io.IOException;
  7. import java.io.InputStreamReader;
  8. import java.net.HttpURLConnection;
  9. import java.net.SocketException;
  10. import java.net.URL;
  11. import java.util.Properties;
  12. public class Test2 {
  13. public static void main(String[] args) {
  14. // getHost("http://www.youdaili.net/Daili/http/2572_4.html") ;
  15. File f = null ;
  16. BufferedReader br = null ;
  17. FileReader fr = null ;
  18. String s = "" ;
  19. String[] host = new String[2] ;
  20. try {
  21. f = new File("E:\\host.txt") ;
  22. fr = new FileReader(f) ;
  23. br = new BufferedReader(fr) ;
  24. s = br.readLine() ;
  25. while(s!=null) {
  26. System.out.println("换一次ip" + s);
  27. host = s.split(":") ;
  28. //******************************
  29. Properties sys = System.getProperties();
  30. sys.put("proxySet","true");
  31. sys.put("proxyHost",host[0]);
  32. sys.put("proxyPort",host[1]);
  33. System.setProperties(sys);
  34. //******************************
  35. getData() ;
  36. s = br.readLine() ;
  37. }
  38. } catch (Exception e) {
  39. System.out.println(e);
  40. }finally {
  41. try {
  42. if(br != null) {
  43. br.close();
  44. }
  45. if(fr != null) {
  46. fr.close();
  47. }
  48. } catch (IOException e) {
  49. e.printStackTrace();
  50. }
  51. }
  52. }
  53. public static void getData() {
  54. System.out.println("进入getData");
  55. URL url ;
  56. int responseCode ;
  57. HttpURLConnection httpURLConnection ;
  58. String str = "" ;
  59. BufferedReader br = null ;
  60. StringBuffer sb = new StringBuffer() ;
  61. InputStreamReader isr = null ;
  62. try {
  63. for(int i=0;i<200;i++){
  64. url = new URL("http://www.uggaustralia.cn/thisisugg/api.php?ctrl=page&action=voteWeibo&pid=4218") ;
  65. httpURLConnection = (HttpURLConnection)url.openConnection() ;
  66. httpURLConnection.setConnectTimeout(5000);
  67. httpURLConnection.setReadTimeout(5000);
  68. httpURLConnection.setRequestProperty("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11") ;
  69. responseCode = httpURLConnection.getResponseCode() ;
  70. if(responseCode ==200){
  71. isr = new InputStreamReader(httpURLConnection.getInputStream(),"GBK") ;
  72. br = new BufferedReader(isr) ;
  73. while((str=br.readLine())!=null){
  74. sb.append(str) ;
  75. }
  76. }else{
  77. throw new SocketException() ;
  78. }
  79. System.out.println(sb.toString());
  80. if(sb.toString().contains("\"data\":2")) {
  81. break ;
  82. }
  83. sb = new StringBuffer() ;
  84. }
  85. } catch (Exception e) {
  86. System.out.println(e);
  87. }finally {
  88. try {
  89. if(br != null) {
  90. br.close();
  91. }
  92. if(isr != null) {
  93. isr.close();
  94. }
  95. } catch (IOException e) {
  96. e.printStackTrace();
  97. }
  98. }
  99. }
  100. /**
  101. * 获得有代理网上的ip
  102. */
  103. public static void getHost(String dailiURL) {
  104. URL url ;
  105. int responseCode ;
  106. HttpURLConnection httpURLConnection ;
  107. String str = "" ;
  108. BufferedReader br = null ;
  109. StringBuffer sb = new StringBuffer() ;
  110. InputStreamReader isr = null ;
  111. try {
  112. url = new URL(dailiURL) ;
  113. httpURLConnection = (HttpURLConnection)url.openConnection() ;
  114. httpURLConnection.setConnectTimeout(5000);
  115. httpURLConnection.setReadTimeout(5000);
  116. httpURLConnection.setRequestProperty("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11") ;
  117. responseCode = httpURLConnection.getResponseCode() ;
  118. if(responseCode ==200){
  119. isr = new InputStreamReader(httpURLConnection.getInputStream(),"utf-8") ;
  120. br = new BufferedReader(isr) ;
  121. str = br.readLine() ;
  122. while(br.readLine()!=null){
  123. if(str.contains("@HTTP#")){
  124. str = str.replace("<p>", "").trim() ;
  125. str = str.substring(0, str.indexOf("@")) ;
  126. str += "\r\n" ;
  127. sb.append(str) ;
  128. }
  129. str = br.readLine() ;
  130. }
  131. System.out.println(sb.toString());
  132. HostwriteToFile(sb.toString()) ;
  133. }
  134. } catch (Exception e) {
  135. e.printStackTrace();
  136. }finally {
  137. try {
  138. if(br != null) {
  139. br.close();
  140. }
  141. if(isr != null) {
  142. isr.close();
  143. }
  144. } catch (IOException e) {
  145. e.printStackTrace();
  146. }
  147. }
  148. }
  149. /**
  150. * 把拿到的代理ip写入文件中
  151. * @param str
  152. */
  153. public static void HostwriteToFile(String str) {
  154. FileWriter fw = null ;
  155. try {
  156. fw = new FileWriter("E:\\host.txt",true) ;
  157. fw.write(str);
  158. fw.flush();
  159. fw.close();
  160. } catch (IOException e) {
  161. e.printStackTrace();
  162. }
  163. }
  164. }
目录
相关文章
|
开发框架 Java 数据库
java----包的命名规范
对包的解释与命名规则
7665 0
java----包的命名规范
|
安全 数据安全/隐私保护
沃通SMIME电子邮件证书申请指南
沃通S/MIME电子邮件证书是全球信任的基础级(Class 1)电子邮件证书,遵循S/MIME安全电子邮件协议,实现电子邮件签名和加密,具有验证发件邮箱真实性、保护电子邮件内容机密性和完整性等功能,防止电子邮件信息泄露、内容篡改、发件方身份仿冒、钓鱼邮件等邮件安全风险
151 0
|
存储 编译器 C++
【C++要笑着学】虚函数表(VBTL) | 观察虚表指针 | 运行时决议与编译时决议 | 动态绑定与静态绑定 | 静态多态与动态多态 | 单继承与多继承关系的虚表(二)
虚表是编译器的实现,而非C++的语言标准。上一章我们学习了多态的概念,本章我们深入探讨一下多态的原理。文章开头先说虚表指针,观察编译器的查表行为。首次观察我们先从监视窗口观察美化后的虚表 _vfptr,再透过内存窗口观察真实的 _vfptr。我们还会探讨为什么对象也能切片却不能实现多态的问题。对于虚表到底存在哪?我们会带着大家通过一些打印虚表的方式进行比对!铺垫完虚表的知识后,会讲解运行时决议与编译时决议,穿插动静态的知识点。文章的最后我们会探讨单继承与多继承的虚表,多继承中的虚表神奇的切片指针偏移问题,这块难度较大,后续我们会考虑专门讲解一下,顺带着把钻石虚拟继承给讲了
264 1
【C++要笑着学】虚函数表(VBTL) | 观察虚表指针 | 运行时决议与编译时决议 | 动态绑定与静态绑定 | 静态多态与动态多态 | 单继承与多继承关系的虚表(二)
|
JavaScript
Vue.js - Vue 中如何引入第三方 JS 库(三)
Vue.js - Vue 中如何引入第三方 JS 库(三)
369 0
Vue.js - Vue 中如何引入第三方 JS 库(三)
|
Unix C语言 iOS开发
C++cin,cout以及常见函数总结,cin,cout格式化控制
C++cin,cout以及常见函数总结,cin,cout格式化控制
C++cin,cout以及常见函数总结,cin,cout格式化控制
|
存储 Linux Windows
通过grub-install命令把grub安装到u盘
<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(89, 145, 0); font-family: 微软雅黑, 黑体; font-size: 18px; line-height: 20px;">通过grub-install命令把grub安装到u盘</
2955 0
QT隐藏窗口标题栏、最大化、最小化、关闭按钮
QT隐藏窗口标题栏、最大化、最小化、关闭按钮
938 0
|
缓存 网络协议 Shell
|
SQL 关系型数据库 MySQL
|
测试技术 C++ Windows
Windows下VS2015编译并使用libcurl.lib静态库(curl:http客户端库c++版本)
Windows下VS2015编译并使用libcurl.lib静态库(curl:http客户端库c++版本)
1040 0