Category Archives: How to Fix

After BS4, select was used to locate

soup>
soup>
soup>
soup>
soup>
soup>
soup>
soup>
soup

The elements of the

soup. Select (‘ #author ‘) from author

soup.select(‘.notice ‘

soup. Select (‘ div span)

Between the

soup. Select (‘ div> Span ‘)

Between the
Select (‘ input[type= ‘button’] ‘) from
soup.
soup.
soup

Beautiful soup4 gets the value of the class property of the tag

BeautifulSoup4 retrieves the value of the class attribute of the tag
Recently, when I was writing a crawler, I suddenly needed to determine whether the class value of the current tag was a specific value. After searching online, I found that it was not very helpful, so I made a note of it.
Using the GET method

html = BeautifulSoup(request,'lxml')
a = html.find_all('a')
for i in a:
	if (i.get('class') == 'xxx'):
		url = i.get('href')
		return url
return None

The above code has the following functions:

    converts the request to BS4 format and stores it in HTML to find all the A tags in HTML, traverse the A tag, and check whether the class value of the current A tag is equal to ‘XXX’. True will return the URL of the current A tag. If the traverse fails to match, it will return None
The get function does more than that. The arguments in get represent the name of the variable you want to get.

When reading the CSV file with Python 3, the Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd0 in position 0: invalid con appears

When reading a CSV file using pd.read_csv(), the following error occurs:
UnicodeDecodeError: ‘UTF-8’ codec can’t decode byte 0xD0 in position 0: invalid continuation byte
The file is not encoded in UTF8, and the system uses UTF8 decoding by default. The solution is to change the corresponding decoding mode.
Solutions:

    find the CSV file – “right after the notepad to open the notepad -” open way “, choose the head menu “file -> save as”, can see the default encoding of the file format for ANSI select encoding a drop-down box, choose the required encoding UTF8, re-save can finally to run the code, the problem is resolved

Solving attributeerror: module ‘urllib’ has no attribute ‘request’

Using urllib in Python 3 is an error like this:

Traceback (most recent call last):
  File "*.py", line 34, in <module>
    html_page = get(URL, req_header)
  File "*.py", line 18, in get_HTML
    request = urllib.request.Request(url, headers=req_header)
AttributeError: module 'urllib' has no attribute 'request'

An error code

import urllib
request = urllib.request.Request(url, headers=req_header)
html = urllib.request.urlopen(request).read()
print (html)

Error reason:
in the Python AttributeError errors there are two kinds of main reason:
1.
2. File with same name exists in project directory

> port urllib.request <>ode>
>

import urllib
import urllib.request
request = urllib.request.Request(url, headers=req_header)
html = urllib.request.urlopen(request).read()
print (html)

Tar: due to the previous error, it will exit with the last error state

Official website to download the mysql connector – odbc – 8.0.21 – Linux – glibc2.12 – x86-64 – bit. Tar. Gz encountered error: tar ZXVF decompression –
Tar: Exits the previous error state because of the previous error
Solution: the source package placed in /home directory can be decompressed successfully
The reason has not been analyzed yet. If you want to see it, you can comment and reply to discuss and communicate with us

JWT and token + redis scheme of spring security

1. Decentralized JWT Token

    decentralized, easy for distributed systems to use Basic information can be placed directly in the token. Username, NICKNAME, ROLE function permission information can be placed directly in the token. Use a bit to represent the user’s functional authority.

Disadvantages: The server cannot actively invalidate the token
2. Centralized Redis Token/Memory Session, etc
Advantages: The server can actively invalidate the token
Cons: Redis queries need to be done every time. Occupying Redis storage space.
Here Redis stores a whitelist of tokens. Other information about the user is also stored in Redis. It takes up a lot of Redis space and queries.
3. Optimization scheme:

    Jwt Token> add TokenId Storing the TokenID field in Redis so that the server can actively control token invalidation sacrifices the decentralized nature of JWT. Use asymmetric encryption. The authentication server that issued the token stores the private key: the private key generates the signature. Other business systems store public keys: The public key verifies the signature.

Here, Redis only stores the blacklist of TokenID, and Redis can also be distributed with separate reads and writes. Token authenticates the server to operate on Redis’ master, and other Redis synchronize the master’s data
 
 
https://www.zhihu.com/question/274566992

Ubutnu’s idea input method candidate box can’t follow the cursor

Problem orientation
In fact, the specific issue of the official seven years ago (reference), but the more pit is that the official has not solved the problem. Simply put, a bug in the JRE running environment of IDEA causes the input method to be unable to locate the mouse position. Therefore, we need to modify the running code of JetBrainsRuntime to fix this problem.
The solution

Modify JetBrainsRuntime

    Download the modified JRE environment
https://pan.baidu.com/s/1S6cEKQS9w9dKqCrlO4QJwg
Extract code: 21MR

    Change the startup environment for IDEA

Change your own JRE directory

/home/ XXX /idea-2020.1/bin/idea.shhome/XXX /idea-2020.1/bin/idea.sh

port IDEA_JDK=/home/ XXX /idea-2020.1/java-11.0.7-jetbrain.>r> export IDEA_JDK=/home/ XXX /idea-2020.1/java-11.0.7-jetbrain
Appendix:
JetBrainsRuntime

Solve the problem of “error msb6006: link.exe Exited, bad method with code 2

I used to write code in Codeblocks when I was learning. When I went to an interview with a company, they gave me VS for a compiler. I had no idea how to use it before. (The reason I didn’t use VS when I wrote my own code was that the VS bucket was too big, and when it was running it was stalling and the computer wasn’t powerful enough, so I had to use Codeblocks.)
To no longer continue to eat this kind of lose, I will go to install a VS2019, write a helloworld after installed, incredibly can’t run, according to the system error can not find the specified file, and this “error MSB6006: link the. Exe has quit, code for 2”, so I went online to find ways to try, what reload solution, adding SDK components, delete files under the installation path, restart the software such as a variety of methods are tried, all useless, for the morning. In the end, I found a solution in a blog, which was to turn off all the security software and firewalls. PS: I had a pop-up blocker on, turned it off, and VS compiled and ran. We’re done.