1, 2021 year end summary
1. CSDN second season Star Program mentor
2. Founder of Nezha community
The hard-working little partners are all clocking in, including daily lonely clocking in, daily reading clocking in, daily video clocking in, etc. don't you join in the study?
Punch in 100 days and become a devil if you don't become a God.
3,Join Nezha community and learn to punch in. You can't stop at all
2, How to learn Java
1. If the foundation is not firm, the earth will shake and the mountains will shake
Steady and steady, step by step, stick to blogging in CSDN, continue to output, and improve the day.
2,Java foundation tutorial series
3. Java basic thought map
4. I also want to join. I want to make an online consultation through UDP, and ask Nezha.
3, Implementing multi thread online consultation with UDP
1. Sender
package com.guor.ipidea; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; import java.net.SocketException; public class TalkSend implements Runnable { DatagramSocket socket = null; BufferedReader reader = null; private int fromPort; private String toIP; private int toPort; public TalkSend(int fromPort, String toIP, int toPort) { this.fromPort = fromPort; this.toIP = toIP; this.toPort = toPort; try { socket = new DatagramSocket(fromPort); reader = new BufferedReader(new InputStreamReader(System.in)); } catch (SocketException e) { e.printStackTrace(); } } @Override public void run() { while (true){ String data = null; try { data = reader.readLine(); byte[] datas = data.getBytes(); DatagramPacket packet = new DatagramPacket(datas,0,datas.length,new InetSocketAddress(this.toIP,this.toPort)); socket.send(packet); if(data.equals("bye")){ break; } } catch (IOException e) { e.printStackTrace(); } } socket.close(); } }
2. Receiving end
package com.guor.ipidea; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.SocketException; public class TalkReceive implements Runnable{ DatagramSocket socket = null; private int port; private String msgFrom; public TalkReceive(int port, String msgFrom) { this.port = port; this.msgFrom = msgFrom; try { socket = new DatagramSocket(port); } catch (SocketException e) { e.printStackTrace(); } } @Override public void run() { while (true){ try { //Ready to receive package byte[] container = new byte[1024]; DatagramPacket packet = new DatagramPacket(container,0,container.length); //Blocking receiving package socket.receive(packet); //Disconnect bye byte[] data = packet.getData(); String receiveData = new String(data,0,data.length); System.out.println(msgFrom + ":" + receiveData); if(receiveData.equals("bye")){ break; } } catch (IOException e) { e.printStackTrace(); } } socket.close(); } }
3,ipidea
package com.guor.ipidea; public class IpIdea { public static void main(String[] args) { new Thread(new TalkSend(7777,"localhost",9999)).start(); new Thread(new TalkReceive(8888,"nezha")).start(); } }
4. Nezha
package com.guor.ipidea; public class Nezha { public static void main(String[] args) { new Thread(new TalkSend(5555,"localhost",8888)).start(); new Thread(new TalkReceive(9999,"ipidea")).start(); } }
4, Give a peach for a plum
1. Nezha gives you a song "little companion dragon children's song: Merry Christmas"
Christmas is coming soon. Primary school students want to listen to children's songs, but they are charged. Nezha had an idea to teach you to use Java net. Download the URL and listen.
2. Get the address of "little companion dragon children's song: Merry Christmas"
3. Code example
package com.guor.test; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; public class MerryTest { public static void main(String[] args) throws IOException { URL url = new URL("https://vd2.bdstatic.com/mda-mm02j05avh9knriq/sc/cae_h264_nowatermark/1638341959033134772/mda-mm02j05avh9knriq.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1639838362-0-0-0ae86199711f5fcbe20fba556a907433&bcevod_channel=searchbox_feed&pd=1&pt=3&abtest=3000203_5&klogid=0562178188"); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); InputStream inputStream = urlConnection.getInputStream(); FileOutputStream fileOutputStream = new FileOutputStream("Merry Christmas.mp4"); byte[] buffer = new byte[1024]; int len; while ((len=inputStream.read(buffer))!=-1){ fileOutputStream.write(buffer,0,len); } fileOutputStream.close(); inputStream.close(); urlConnection.disconnect(); } }
4. Download to local
5. Local play
5, Is it risky to download it casually?
1. How to solve it?
Because we collect data too fast, which puts too much pressure on the other party's server. The other party can trace back and find us easily, which will lead to our ip being blocked.
If we want to stop being blocked, we need to replace the IP to grab data information. So how to solve this problem?
- Found an http
- Crawl ip
- Verify ip validity
- Record ip
2. Introduction to ipidea
ipidea is an overseas crawler agent, providing overseas residential ip and overseas static ip. It is mainly engaged in data collection business and maintains long-term cooperation with multiple data collection enterprises. It provides 90 million ip resources and can customize the ip rotation time according to the capture requirements, so as to avoid being blocked by the website. It supports account secret authentication and API extraction to extract ip resources. The most important thing is to support free testing.
The world's leading Internet big data IP Resources
3. ipidea generates api links, which can be applied by copying links
Common or transparent ip will waste a lot of time while testing and extracting ip. Finally, it may be invalid ip. Only proxy ip can be used in a simpler way. Its practicability, stability and security can be guaranteed. Use IPIDEA for ip extraction.
4. Generate proxy ip operation usage
During server maintenance or self-contained proxy ip, many of them will not be maintained. Therefore, many proxy ip appear. The use of proxy ip is relatively simple. If there are problems, you can feed back to the agent in time and find technicians to solve them. Crawlers are used to quickly complete the work requirements. Using agents can save working time and complete the work quickly.
6, 2022, beautiful vision
1. Publishing black books
Java learning route summary, brick movers counter attack Java Architects
Brick movers counter attack Java architects is also trying to catch up with the draft. Nezha's first black book will meet you in half a year and wait and see.
2. The goal of Nezha community
- Lead 1000 small partners to become a million fans blogger;
- Lead 100 small partners to publish their own black books;
- Lead 10 small partners to realize the dream of financial freedom;
3. ① ② ③ ④ group is full, and ⑤ group is in hot recruitment.
7, Nezha community
- Vue.js family bucket zero foundation introduction to advanced project practice
- Java high concurrency programming guide
- 100 million traffic Java high concurrency and network programming practice
- Python from introduction to artificial intelligence practice
When you have confidence, courage and perseverance, there is nothing you can't do in the world.
Previous: Java learning route summary, brick movers counter attack Java Architects
Next: Summary of Java learning route (mind map)