当前位置:   article > 正文

伪造一个IP地址来访问网站数据_c#如何虚拟100个id地址去访问同一个网址

c#如何虚拟100个id地址去访问同一个网址
  1. public class QueryKuaiDiFetch {
  2. public static final String QUERYURL = "http://www.kuaidi100.com/query?";
  3. public static String setUrl(String logisticsCode, String logisticsNo) {
  4. String temp = String.valueOf(Math.random());
  5. StringBuilder sb = new StringBuilder(QUERYURL);
  6. sb.append("tpye=").append(logisticsCode).append("&");
  7. sb.append("postid=").append(logisticsNo).append("&");
  8. sb.append("temp=").append(temp);
  9. return sb.toString();
  10. }
  11. public static String queryData(String num, Integer com) {
  12. String line = "";
  13. String temp = String.valueOf(Math.random());
  14. String logisticsCode = "";
  15. if (com == 0) {
  16. logisticsCode = "shentong";
  17. } else {
  18. logisticsCode = "zhongtong";
  19. }
  20. String url = "http://www.kuaidi100.com/query?type=" + logisticsCode + "&postid=" + num + "&temp=" + temp + "&order=asc";
  21. try {
  22. URL realURL = new URL(url);
  23. HttpURLConnection conn = (HttpURLConnection) realURL.openConnection();
  24. String ip = randIP();
  25. conn.setRequestProperty("X-Forwarded-For", ip);
  26. conn.setRequestProperty("HTTP_X_FORWARDED_FOR", ip);
  27. conn.setRequestProperty("HTTP_CLIENT_IP", ip);
  28. conn.setRequestProperty("REMOTE_ADDR", ip);
  29. conn.setRequestProperty("Host", "");
  30. conn.setRequestProperty("accept", "*/*");
  31. conn.setRequestProperty("connection", "Keep-Alive");
  32. conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36");
  33. conn.connect();
  34. int responseCode = conn.getResponseCode();
  35. if (responseCode == HttpURLConnection.HTTP_OK) {
  36. InputStream inputStream = conn.getInputStream();
  37. BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
  38. while ((line = reader.readLine()) != null) {
  39. System.out.println(line);
  40. return line;
  41. }
  42. reader.close();
  43. conn.disconnect();
  44. }
  45. } catch (Exception e) {
  46. e.printStackTrace();
  47. }
  48. return line;
  49. }
  50. public static String randIP() {
  51. Random random = new Random(System.currentTimeMillis());
  52. return (random.nextInt(255) + 1) + "." + (random.nextInt(255) + 1)
  53. + "." + (random.nextInt(255) + 1) + "."
  54. + (random.nextInt(255) + 1);
  55. }
  56. }

工作忙,但还是要记得点外卖哦

欢迎关注我的外卖公众号,领优惠红包!还有电影票、酒店、滴滴红包哦

 

 

我刚做的小程序哦,欢迎交流程序问题哦~ 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/844369
推荐阅读
相关标签
  

闽ICP备14008679号