Dynamic data loading processing
I. Lazy loading of pictures
- What is lazy loading of pictures?
- Case analysis: Grab image data from webmaster material http://sc.chinaz.com/
-
– The operation result shows that we can get the name of the picture, but the link gets empty. After checking, there is no problem with the xpath expression. What is the reason?
-
The concept of lazy loading of images:
-
Lazy loading of images is a webpage optimization technology. As a kind of network resource, pictures are the same as ordinary static resources when they are requested, they will occupy network resources, and loading all pictures of the entire page at one time will greatly increase the loading time of the first screen of the page. In order to solve this problem, the front-end and back-end cooperation allows the picture to be loaded only when it appears in the current window of the browser. The technology that reduces the number of requests for the first-screen picture is called “picture lazy loading”.
-
-
How do websites generally implement image lazy loading technology?
-
In the source code of the webpage, a “pseudo attribute” (usually src2, original…) is used in the img tag to store the real image link and It is not directly stored in the src attribute. When the picture appears in the visual area of the page, the pseudo attribute will be dynamically replaced with the src attribute to complete the loading of the picture.
-
-
Follow-up analysis of the webmaster material case: After carefully observing the structure of the page, it is found that the link to the picture on the webpage is stored in the pseudo Attributes
Two.selenium
- What is selenium?
-
is a third-party library of Python. The interface provided to the outside can operate the browser, and then let the browser complete the automated operation.
-
-
Environment setup
-
Install selenum: pip install selenium
-
Get the driver of a certain browser (take Google Chrome as an example)
-
Google Chrome driver download address:
http:/ /chromedriver.storage.googleapis.com/index.html
-
The downloaded driver must be consistent with the browser version. You can follow the
http: //blog.csdn.net/huilan_same/article/details/51896672 provides corresponding version mapping table
-
-
Effect display:
Code introduction:
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2037 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC