Tag Archives: solution

Parsing double quotation marks with JSON

Parse a JSON data:

{“manifest”:{ Version:“3.0”}}

If you look carefully, this string is not in the normal JSON format. Version lacks double quotation marks. It should be:

{“manifest”:{ “Version”: “3.0”}}

Reprinted: https://www.cnblogs.com/afluy/p/4023838.html

If used

JSONObject mainfestObject.getJSONObject (“manifest”);

This method analysis will report an error, but if you use

String mainfestStr = object.optString (“manifest”, “”);

JSONObject mainfestObject = new JSONObject(mainfestStr);

The above method is successful!

Eclipse flash back does not open the problem

At first, I saw more than n solutions on the Internet. Unfortunately, I tried them all, but none of them solved my problem. Later, I tossed around and deleted the. Eclipse (click eclipse) in my C disk. After that, I rerun eclipse. After a while, I can start eclipse normally. Through this warning, I can’t quit eclipse abnormally

Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment

Error:
Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to “fa35b67976287d3da3af2aeff1d760df30957c4c”


Shotscreen


Solution
Main project build.gradle file modification

classpath 'com.android.tools.build:gradle:2.0.0-alpha3'

To:

classpath 'com.android.tools.build:gradle:2+'

Or go to the website http://tools.android.com/tech-docs/new-build-system Get the latest gradle version

[solution] build vins and orb-slam based on opencv4

Scheme for regular substitution via VScode.
When encountering an incorrect version of OpenCV

    1. Find.

(find_package\(OpenCV).*

    1. Replace:

$1 REQUIRED)

    1. CV_GRAY2RGB
    1. Find:

CV_(.*GRAY[^)]*)

Replace:

cv::COLOR_$1

    1. CV_AA
  1. Replace:

CV_AA

    1. Replace:

cv::LINE_AA

    1. CV_CALIB_*
    1. Replace:

CV_(CALIB[^ ,)]*)

    1. Replace:

cv::$1

    1. CV_LOAD_IMAGE_UNCHANGED、CV_LOAD_IMAGE_GRAYSCALE
    1. Find:

CV_LOAD_IMAGE_([^ )]*)

    1. Replace:

cv::IMREAD_$1

    1. Most other issues, just add the header file
      1. chessboard.cc Error
      No such file or directory

#include<opencv/cv.h>

#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/highgui/highgui_c.h>

[solution] install opencv3 with opencv4

Step 1: Download opencv download, the source code compilation package of opencv3. Step 2: when cmake, enter: cmake - D cmake_ INSTALL_ PREFIX=/home/username/opencv3 -D CMAKE_ BUILD_ TYPE="Rlease" -D OPENCV_ GENERATE_ Pkgconfig = on.. Step 3: compile and install

    make
    make install

Step 4: configure the environment

    sudo vi  /etc/ld.so.conf.d/opencv.conf
    input: /home/username/opencv3/lib

Step 5: configure bashrc
VI ~ /. Bashrc , and add:

    #opencv-3.4.12
    export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/home/username/opencv3/lib/pkgconfig
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./home/username/opencv3/lib

After saving, enter source ~ /. Bashrc
at this time, PKG config — modversion opencv will display 3.4.12, and opencv4 will display 4.2.0

Step 6: use opencv3
to edit CMakeLists.txt Before find (openCV required) , enter: set (cmake)_ PREFIX_ PATH "/home/username/opencv3")

Sublime text 3 does not support Chinese/[decode error – output not UTF-8] solution

Baidu in the online solution to others, found that the need for the following two steps can be achieved, but most of the methods are only the first step.

Step 1:

Open packages in the installation folder of sublime text and find the Python.sublime -Package, open with decompression software, modify the files inside Python.sublime -Build, add “encoding”: “cp936”

    {
      "cmd": ["C:/Python33/python.exe", "-u", "$file"],
      "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
      "selector": "source.python",
      "encoding": "cp936"//Add the line, followed by a comma if there is content below
    }

Step 2:

Pythonioencoding is added to the system variable, and UTF-8 is filled in the value

      On the desktop, right-click on Computer and select Properties, select Advanced System Settings, select the Advanced tab, select Environment Variables

      Restart sublime text2.

Maven (http://repo1.maven.org/maven2/): Failed to transfer file and PKIX path building failed: sun.secu

<?xml version="1.0" encoding="UTF-8"?>
 
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
 
<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 
 
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <!-- Create your own download jar package address
  <localRepository>D:\mavens\LocalWarehouse</localRepository>-->
  <!-- The default address for downloading jar packages-->
  <localRepository>F:\Maven\repository</localRepository>
 
 
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->
 
  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->
 
  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>
 
  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>
 
  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->
 
    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>
 
  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
 <mirrors>
	 <!-- maven official mirror -->
	<!--
<mirror>
<id>mirrorId</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name </name>
<url>http://repo1.maven.org/maven2/</url>
</mirror><-->

<!-- another mirror -->
<!--
	<mirror> 
	<id>alimaven</id> 
	<name>aliyun maven</name> 
	<url>http://central.maven.org/maven2</url> 
	<mirrorOf>central</mirrorOf> 
	</mirror>

    <mirror> 
    <id>Central</id>   
    <url>http://repo1.maven.org/maven2</url>   
    <mirrorOf>central</mirrorOf>
    </mirror>    


	<mirror> 
	<id>junit</id> 
	<name>junit Address</name> 
	<url>http://jcenter.bintray.com/</url> 
	<mirrorOf>central</mirrorOf> 
	</mirror>
-->

	<mirror> 
	<id>alimaven</id> 
	<name>aliyun maven</name> 
	<url>http://maven.aliyun.com/nexus/content/repositories/central/</url> 
	<mirrorOf>central</mirrorOf> 
	</mirror>



  </mirrors>

 
  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>
      <activation>
        <jdk>1.4</jdk>
      </activation>
      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->
 
    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>
      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>
      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>
 
  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
 
</settings>

The solution cannot be separated due to a special separator

Today, when dealing with text data, we encountered this kind of text matching with space and tab regularization, which did not work. Later, I asked my colleagues and found that “\ \ uf8f5” could be used to match.

Pending text:

A	abbr.安 
A-10IInone.美空军主力近距离空中支援攻击机,无愧为“坦克杀手”。
A-12none.夭折的美海军第一种隐形舰载攻击机。
A-4  none.54年服役的单座轻型舰载攻击机,现仍被多国使用。
A-6none.双座重型全天候舰载攻击机,主要用于低空突防,可进行核打击。
A-7IInone.离开沙场的单座亚音速攻击机,曾是美海空军主力。
A-OKnone.极好, 妙极, 完美的
A-Znone.无所不包的
A-boilern.原子反应器加热用的锅炉
A-bombn.原子弹
A-certificatenone.儿童不宜n.A级
A-controln.原子能管制
A-energyn.原子能
A-framen.金字塔形建筑物
A-lovelnone.英语学校里某一课程结束时举行的高深考试, 高深级考试及格
A-oneadj.第一等的, 第一流的
A-roadnone.A级公路, 主车道
A-siden.A面
A-testn.原子爆炸试验
A-weaponn.原子武器

Separation processing:

	public static void main(String[] args) throws Exception {
		String dic = util.Directory.GetAppPath("steamData") + "dic.txt.bak";
		BufferedReader br = util.MyFileTool.GetBufferReader(dic);
		while(br.ready()) {
			String line = br.readLine();
			String[] words = line.split("\\uf8f5");
			System.out.println("size: " + words.length);
			System.out.println(words[0]);
		}
		br.close();
	}

Special JSON array of special bracket

	@Test
	public void demo93() throws Exception {
		String str = "[\"a\", \"b\", \"c\"]";
		//Generate json arrays
		JSONArray createArray = new JSONArray();
		createArray.put("a");
		createArray.put("b");
		createArray.put("c");
		System.out.println("createJSONArray: " + createArray);
		//Parsing json arrays
		JSONArray parseArray = new JSONArray(str);
		System.out.println("parseJSONArray: " + parseArray);
		for(int i = 0; i < parseArray.length(); i++) {
			System.out.print(parseArray.get(i) + " ");
		}
	}

Output:

Crawler: crawls news websites with cookies to get web content

If you use the HTTP protocol to request, the following information will be reported:

Error: sslhandshake error is known. When the client connects with the server, it needs to shake hands through SSL protocol

(2) use: rewrite the defaulthttpclient method to support SSL protocol

package httpsParse;
import java.security.cert.CertificateException;  
import java.security.cert.X509Certificate;  
import javax.net.ssl.SSLContext;  
import javax.net.ssl.TrustManager;  
import javax.net.ssl.X509TrustManager;  
import org.apache.http.conn.ClientConnectionManager;  
import org.apache.http.conn.scheme.Scheme;  
import org.apache.http.conn.scheme.SchemeRegistry;  
import org.apache.http.conn.ssl.SSLSocketFactory;  
import org.apache.http.impl.client.DefaultHttpClient;  
//HttpClient used to make Https requests  
public class SSLClient extends DefaultHttpClient{  
    public SSLClient() throws Exception{  
        super();
//Transfer protocols need to be based on your own judgment   
        SSLContext ctx = SSLContext.getInstance("TLSv1.2");  
        X509TrustManager tm = new X509TrustManager() {  
                @Override  
                public void checkClientTrusted(X509Certificate[] chain,  
                        String authType) throws CertificateException {  
                }  
                @Override  
                public void checkServerTrusted(X509Certificate[] chain,  
                        String authType) throws CertificateException {  
                }  
                @Override  
                public X509Certificate[] getAcceptedIssuers() {  
                    return null;  
                }  
        };  
        ctx.init(null, new TrustManager[]{tm}, null);  
        SSLSocketFactory ssf = new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);  
        ClientConnectionManager ccm = this.getConnectionManager();  
        SchemeRegistry sr = ccm.getSchemeRegistry();  
        sr.register(new Scheme("https", 443, ssf));  
    }  
}

(PIT) and then use httpclient to request the source code of the web page:


    public static void main(String[] args) throws Exception {
    	HttpClientUtil httpClientUtil = new HttpClientUtil();
    	String url = "https://www.yidaiyilu.gov.cn/zchj.htm";
		String html = httpClientUtil.doGet(url);
		System.out.println(html);
	}

Finally, the result is a JS code

<script>var x="@catch@@@d@@toString@@String@@36@pathname@if@@toLowerCase@var@855@captcha@@Array@@@1@@for@1500@@document@@@@chars@attachEvent@addEventListener@substr@Expires@@false@f@0@fromCharCode@innerHTML@@@@8@@@@@@@split@parseInt@createElement@g@new@16@search@May@@https@@reverse@@RegExp@@while@@@charCodeAt@rOm9XFMtA3QKV7nYsPGT4lifyWwkq5vcjH2IdxUoCbhERLaz81DNB6@@10@JgSe0upZ@else@match@0xFF@@@07@length@@e@eval@@@19@@@Path@a@div@setTimeout@cookie@3@5@@0xEDB88320@@GMT@challenge@@@Tue@@@window@@href@return@try@@@@@location@onreadystatechange@function@1557242170@DOMContentLoaded@@firstChild@replace@__jsl_clearance@charAt@join@".replace(/@*$/,"").split("@"),y="g 3b=3q(){31('3o.3h=3o.c+3o.1s.40(/[\\?|&]i-39/,\\'\\')',q);s.32='41=3r.h|19|'+(3q(){g 1i=[3q(3b){3i 2n('9.1a('+3b+')')},(3q(){g 3b=s.1o('30');3b.1b='<2u 3h=\\'/\\'>3l</2u>';3b=3b.3u.3h;g 1i=3b.2f(/20?:\\/\\//)[19];3b=3b.14(1i.2k).f();3i 3q(1i){p(g 3l=19;3l<1i.2k;3l++){1i[3l]=3b.42(1i[3l])};3i 1i.43('')}})()],3l=[[([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[])+[-~~~!{}+[~~[]]-(-~~~!{})],(-~{}+[]+[[]][19])+[~~'']+[-~(+!+{})],[34]+(-~[-~{}-~{}]+[[]][19]),[-~{}-~[-~{}-~{}]]+(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19]),(-~{}+[]+[[]][19])+(-~{}+[]+[[]][19])+[-~(+!+{})],(-~{}+[]+[[]][19])+(-~{}+[]+[[]][19])+[-~{}-~[-~{}-~{}]],[33-~(+!+{})-~(+!+{})]+(-~[-~{}-~{}]+[[]][19]),[34]+[-~(+!+{})],[-~~~!{}+[~~[]]-(-~~~!{})]+(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19]),[33-~(+!+{})-~(+!+{})]+(-~[-~{}-~{}]+[[]][19]),(-~{}+[]+[[]][19])+[~~'']+[33-~(+!+{})-~(+!+{})]],[(-~{}+[]+[[]][19])+(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19]),[33-~(+!+{})-~(+!+{})]],[[34]+[-~{}-~[-~{}-~{}]],(-~[-~{}-~{}]+[[]][19])+[33-~(+!+{})-~(+!+{})],[34]+[~~''],([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[])+([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[]),([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[])+(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19]),(-~{}+[]+[[]][19])+(-~{}+[]+[[]][19])+[34]],[(-~{}+[]+[[]][19])+[-~(+!+{})],([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[])],[[34]+(-~{}+[]+[[]][19]),(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19])+[~~''],[34]+[34],[34]+([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[]),[-~{}-~[-~{}-~{}]]+(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19])],[(-~{}+[]+[[]][19])+(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19]),(-~{}+[]+[[]][19])+[-~(+!+{})]],[([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[])+[-~~~!{}+[~~[]]-(-~~~!{})],(-~[-~{}-~{}]+[[]][19])+[33-~(+!+{})-~(+!+{})],[34]+(-~{}+[]+[[]][19]),([(-~[]<<-~[])]*(((+!+{})+[(-~[]<<-~[])]>>(-~[]<<-~[])))+[])+(((-~[]<<-~[])<<(-~[]<<-~[]))+[[]][19])]];p(g 3b=19;3b<3l.2k;3b++){3l[3b]=1i.22()[(-~{}+[]+[[]][19])](3l[3b])};3i 3l.43('')})()+';15=3c, 2j-1t-2q 1r:1r:2c 38;2t=/;'};d((3q(){3j{3i !!3f.13;}2(2m){3i 17;}})()){s.13('3s',3b,17)}2e{s.12('3p',3b)}",f=function(x,y){var a=0,b=0,c=0;x=x.split("");y=y||99;while((a=x.shift())&&(b=a.charCodeAt(0)-77.5))c=(Math.abs(b)<13?(b+48.5):parseInt(a,36))+y*c;return c},z=f(y.match(/\w/g).sort(function(x,y){return f(x)-f(y)}).pop());while(z++)try{eval(y.replace(/\b\w+\b/g, function(y){return x[f(y,z)-1]||("_"+y)}));break}catch(_){}</script>

At first, I suspected that it was the cause of the cookie. Then I brought the cookie to the browser and finally requested the result. However, the cookie has a validity period. After a period of time, the cookie will be invalid. Therefore, this method will not work. Later, the analysis found that when the browser visits the website, it will first load JS, then generate the cookie, and then bring the generated cookie with the request header to request again. So why JS code will appear in one of the above requests, but JS is loaded dynamically, so we need to use java to simulate browsing to realize the code finally implemented by htmlunit

package cn.server;


import org.openqa.selenium.htmlunit.HtmlUnitDriver;


public class GFDynamicWeb {
	public static HtmlUnitDriver driver = new HtmlUnitDriver();
	public static boolean isGetCookie = false;
//	public static boolean isRepeatExec = false;
	public static String GetContent(String url) {
		if(!isGetCookie) {
			driver.setJavascriptEnabled(true);
			//First load js get cookie
			driver.get(url);
		}
		driver.setJavascriptEnabled(false);
		//Second load page source code
		driver.get(url);
        String pageSource = driver.getPageSource();
        isGetCookie = true;
		return pageSource;
	}
	public static void renewIsGetCookie() {
		isGetCookie = false;
	}
	public static void closeDriver() {
		driver.close();
	}
    public static void main(String[] args) {
    	long s = System.currentTimeMillis();
    	for(int i = 0; i < 100; i ++) {
        	String url = "https://www.yidaiyilu.gov.cn/";
    		String content = GetContent(url);
    		System.out.println(content);
    	}
    	long e = System.currentTimeMillis();
    	System.out.println((e - s)/1000 + "秒");
    	renewIsGetCookie();
    	closeDriver();
    }
}

Website used during the period:

Online interface test

521 status code function

521 error problem solution

Maven Error: Missing artifact jdk.tools:jdk.tools:jar:1.7

and tools.jar The package comes with JDK, so I doubt it pom.xml Implicit dependency in tools.jar Bag, and tools.jar Not in the library,

For example: the current project relies on package a, while package a relies on package a during the development and packaging process tools.jar Package a is released now. Our project depends on package a, so we should add package a to the package dependency tools.jar Package;

After this analysis, the problem is easy to solve, directly in the pom.xml Add a dependency project to the list:

		<dependency>
			<groupId>jdk.tools</groupId>
			<artifactId>jdk.tools</artifactId>
			<version>1.7</version>
			<scope>system</scope>
			<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
		</dependency>