Study concluded -2020-01-04

Foreword

This article describes mainly the study Python3 reptiles, as well as os, re, type (), super () is

Modified: 2020-01-04

Sky lone

  0X01; Python3 reptiles summary

  First, let's look at what is reptiles, nature "reptiles" in my opinion is to use the code to replace the artificial pageview an act. This way if it is relatively simple. Let's take a look at how people operate WEB browser is Internet browsing data.

  Here is a look at how to communicate with the WEB data:

    1; WEB browser request packet to the data required to send data url address.

    2; validated data server (by Cookie, etc.) by the WEB browser returns required.

    3; WEB browser through a particular format to analyze unpacking, displaying information.

  According to the above analysis, we understand, hoping to use the code to replace the behavior of the above analysis.

    1; WEB browser sends the packet to request for the desired data.

    1.1; Python3 use of urllib in which functions to perform reptiles, wherein the request module may simulate the behavior of the web to transmit data packets. the urllib.request.urlopen () can send packets directly, of course, if desired the full WEB analog transmission packet, the packet transmission can also be customized. Wherein urllib.request.Request () to customize WEB data packet to be sent by urllib.request.urlopen ().

    1.2; custom packet completed that we will go into where to send the packet it? WEB browser is used to find the corresponding server via URL. Through the code, of course, too, where we can use the module to module urllib.parse URL structure we need.

    3; WEB browser through a particular format to analyze unpacking, displaying information.

    For the return to all of the data we do not need, so we need to filter the data. Common methods of screening data can be by BS library, regular expressions, xpath, jsonpath, selenium. To filter the data.

 

  0X02; Python3 os library

    1; os.access (path, mode) is a method to try to access the role uid / gid path.

    2; os.chdir (path) The method for switching the working path.

    3; os.chmod (path, mode) method is used to change the file or directory permissions.

    4; os.chown (path, uid, gid) method for a user to change the file owner.

    5; os.makedirs (path, mode) recursive common directory.

    6; os.path.exists (path) to determine whether a path exists.

  

  0X03; Python3 re library

    1; re.match (pattern, string, flags = 0) from a string matching the start position.

    2; re.search (pattern, string, flags = 0) scans the entire string and returns a matching object.

    3; re.sub, re.subn replacement string

    4; re.findall match all keywords

    5; re.compile compiling a regular expression

 

  0X04; Python3 objects

    1; defining classes, Class keyword

    2; object instance  

    3; inheritance

    4; method overrides

 

  0X05;Python3 type()

    1; type () function if you have only the first argument of type object is returned

  

  0X06;Python3 super()

    1; super () method call the parent class

  

  

 

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/aaron456-rgv/p/12150713.html