Home > other >  Python selenium webdriver operation browser display a picture, how images are directly related to th
Python selenium webdriver operation browser display a picture, how images are directly related to th

Time:10-07

1. You can't use the SRC address download method, because the picture is a dynamic image of SRC, every time to obtain the timestamp is the time, so every request of the images are not the same as

2. Cannot use screenshot method, because the original image resolution is 800 * 800 pixels image, and the pictures shown in the browser in the framework of a 50 * 50, so the resolution of the screenshots can only get 50 * 50, cannot meet the needs of the resolution of the

Please teach people

CodePudding user response:

Very difficult problems?

CodePudding user response:

So can only use requests or selenium climb took, is to send the request for the returned images by SRC value after download (browser is how it works, according to the content of the return of the link to send the request again), then download the pictures is the first image, rather than the browser to display images and then send the request to download (this is the second time request the picture), mentioned in article 1 of the dynamic images, if it is only the GIF can use tool to each frame in the GIF image are extracted, and see which one is you need, if it is only for every request in turn provide a background image, it can analyze which provide pictures every time, then sending multiple requests only save corresponding to the requested pictures directly loaded into memory, look at the python is not directly from the library for the image url,

CodePudding user response:

refer to the second floor goose hill 1990 response:
so can only be used for requests or selenium climb took, is to send the request for the returned images by SRC value after download (browser is how it works, according to the content of the return of the link to send the request again), then download the pictures is the first image, rather than the browser display images and then send the request to download (this is the second time request the picture), mentioned in article 1 of the dynamic images, if it is only the GIF can use tool to each frame in the GIF image are extracted, and see which one is you need, if it is only for every request in turn provide a background image, it can analyze which provide pictures every time, then sending multiple requests only save corresponding to the requested pictures directly loaded into memory, look at the python is not directly from the library for the image url,

You said to not line, such as
The SRC for https://login.sina.com.cn/cgi/pin.php? R=10914609 & amp; S=0 & amp; P=d730ab3f1cd4ac64bfdb958f210a54f13 tc - 495
SRC hasn't changed, but each request back pictures are different

CodePudding user response:

references a little lover's reply: 3/f
Quote: refer to the second floor goose hill 1990 response:

So can only use requests or selenium climb took, is to send the request for the returned images by SRC value after download (browser is how it works, according to the content of the return of the link to send the request again), then download the pictures is the first image, rather than the browser to display images and then send the request to download (this is the second time request the picture), mentioned in article 1 of the dynamic images, if it is only the GIF can use tool to each frame in the GIF image are extracted, and see which one is you need, if it is only for every request in turn provide a background image, it can analyze which provide pictures every time, then sending multiple requests only save corresponding to the requested pictures directly loaded into memory, look at the python is not directly from the library for the image url,

You said to not line, such as
The SRC for https://login.sina.com.cn/cgi/pin.php? R=10914609 & amp; S=0 & amp; P=d730ab3f1cd4ac64bfdb958f210a54f13 tc - 495
SRC hasn't changed, but each request return of the images are different

This is because the content of the return is a base64 encoding, dynamically generated images on the server side, after base64 encryption into a string with HTML documents sent to the client, then the browser will automatically decoding display, so although SRC, but is not the same as the display content (dynamically generated each time),
You can use the F12 Source in the developer tools window see the returned string is different every time, I use the online tool http://imgbase64.duoshitong.com/decoding, and the page display pictures, pay attention to the need to add a prefix data: image/PNG; Base64,,
so you can try to read the images in HTML documents base64 encoding and decoding (python seems to bring the decoded packet), don't through the browser, with requests to obtain the response, the response is the content of the original content, which will contain the image coding, in addition, you send this sina authentication code example might not be appropriate, because the authentication code, after all, a small base64 encoding is not big, but also dynamically generated is easy, if it is photos such as pictures, the server can't randomly generated, the most is the background of random choose photos and then a base64 encoding to send,

CodePudding user response:

reference goose hill, 4/f, 1990 response:
Quote: refer to the third floor little lover's reply:

Quote: refer to the second floor goose hill 1990 response:

So can only use requests or selenium climb took, is to send the request for the returned images by SRC value after download (browser is how it works, according to the content of the return of the link to send the request again), then download the pictures is the first image, rather than the browser to display images and then send the request to download (this is the second time request the picture), mentioned in article 1 of the dynamic images, if it is only the GIF can use tool to each frame in the GIF image are extracted, and see which one is you need, if it is only for every request in turn provide a background image, it can analyze which provide pictures every time, then sending multiple requests only save corresponding to the requested pictures directly loaded into memory, look at the python is not directly from the library for the image url,

You said to not line, such as
The SRC for https://login.sina.com.cn/cgi/pin.php? R=10914609 & amp; S=0 & amp; P=d730ab3f1cd4ac64bfdb958f210a54f13 tc - 495
SRC hasn't changed, but each request return of the images are different

This is because the content of the return is a base64 encoding, dynamically generated images on the server side, after base64 encryption into a string with HTML documents sent to the client, then the browser will automatically decoding display, so although SRC, but is not the same as the display content (dynamically generated each time),
You can use the F12 Source in the developer tools window see the returned string is different every time, I use the online tool http://imgbase64.duoshitong.com/decoding, and the page display pictures, pay attention to the need to add a prefix data: image/PNG; Base64,,
so you can try to read the images in HTML documents base64 encoding and decoding (python seems to bring the decoded packet), don't through the browser, with requests to obtain the response, the response is the content of the original content, which will contain the image coding, in addition, you send this sina authentication code example might not be appropriate, because the authentication code, after all, a small base64 encoding is not big, but also dynamically generated is easy, if it is photos such as pictures, the server can't randomly generated, the most is the background of random choose photos and then a base64 encoding to send,


Could you tell me how to turn the base64 string loaded into memory

CodePudding user response:

small enthusiasts reference 5 floor response:
Quote: reference goose hill, 4/f, 1990 response:

Quote: refer to the third floor little lover's reply:

Quote: refer to the second floor goose hill 1990 response:

So can only use requests or selenium climb took, is to send the request for the returned images by SRC value after download (browser is how it works, according to the content of the return of the link to send the request again), then download the pictures is the first image, rather than the browser to display images and then send the request to download (this is the second time request the picture), mentioned in article 1 of the dynamic images, if it is only the GIF can use tool to each frame in the GIF image are extracted, and see which one is you need, if it is only for every request in turn provide a background image, it can analyze which provide pictures every time, then sending multiple requests only save corresponding to the requested pictures directly loaded into memory, look at the python is not directly from the library for the image url,

You said to not line, such as
The SRC for https://login.sina.com.cn/cgi/pin.php? R=10914609 & amp; S=0 & amp; P=d730ab3f1cd4ac64bfdb958f210a54f13 tc - 495
SRC hasn't changed, but each request return of the images are different

This is because the content of the return is a base64 encoding, dynamically generated images on the server side, after base64 encryption into a string with HTML documents sent to the client, then the browser will automatically decoding display, so although SRC, but is not the same as the display content (dynamically generated each time),
You can use the F12 Source in the developer tools window see the returned string is different every time, I use the online tool http://imgbase64.duoshitong.com/decoding, and the page display pictures, pay attention to the need to add a prefix data: image/PNG; Base64,,
nullnullnullnullnullnullnullnullnullnull
  • Related