Tokyo Olympic Games is fervent, the Olympic athletes are working hard for their country to win a medal. China is a big sports country, and ranks first in the number of MEDALS in the Olympic Games every year. From the current number of winners see China is temporarily leading, in the Chinese Olympic member champion most let everyone pay attention to is, 2000 years Of Yang Qian actually also big outstanding students. This should make parents proud to have an Olympic champion and an excellent student daughter.

Without further ado, as a reptilian, today we share how to use Python to query the latest Olympic gold medal rankings every day. Our data source can be obtained from the official website of CCTV.com. Gold medal list: 2020.cctv.com/medal_list/

We can obtain specific acquirer information through data connection, as shown in the following code example:

import java.io.IOException; import java.net.Authenticator; import java.net.InetSocketAddress; import java.net.PasswordAuthentication; import java.net.Proxy; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; Public class Demo {// Proxy verification information Final static String ProxyUser = "username"; final static String ProxyPass = "password"; // Proxy server (www.16yun.cn) final static String ProxyHost = "t.16yun.cn"; // Proxy server (www.16yun.cn) final static String ProxyHost = "t.16yun.cn"; final static Integer ProxyPort = 31111; Final static String ProxyHeadKey = "proxy-tunnel "; public static String getUrlProxyContent(String url) { Authenticator.setDefault(new Authenticator() { public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(ProxyUser, ProxyPass.toCharArray()); }}); // set proxy-tunnel Random Random = new Random(); int tunnel = random.nextInt(10000); String ProxyHeadVal = String.valueOf(tunnel); Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(ProxyHost, ProxyPort)); Document doc = jsoup.connect (url).timeout(3000).header(ProxyHeadKey, ProxyHeadVal).proxy(proxy).get(); if(doc ! = null) { System.out.println(doc.body().html()); } } catch (IOException e) { e.printStackTrace(); } return null; } public static void main(String[] args) throws Exception {// Target page to be accessed String targetUrl = "https://2020.cctv.com/medal_list/"; getUrlProxyContent(targetUrl); }}Copy the code

I hope that in the next games, China continue to cheer!