How to crawl high-definition 4K desktop wallpaper by Python
This article mainly shows you "Python how to climb high-definition 4K desktop wallpaper", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Python how to climb high-definition 4K desktop wallpaper" this article.
Target URL:
Http://www.netbian.com/
Partial code
Import tool
Import requestsimport parsel
Request website data
Url = 'http://www.netbian.com/index_2.htm'cookies = {' Cookie':'_ cfduid=d892faf2d87d3fd9bd75b5606165cd68c1598431866; Hm_lvt_14b14198b6e26157b7eba06b390ab763=1598431867,1598516099; xygkqecookieinforecord=%2C12-22800%2C19-22803%2C12-22835%2C19-22699%2C19-22649%2C19-22775% 2C; Hm_lpvt_14b14198b6e26157b7eba06b390ab763=1598516285'} headers = {'User-Agent':' Mozilla/5.0 (Windows NT 10.0 WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', 'Referer':' http://www.netbian.com/'}response = requests.get (url=url, headers=headers, cookies=cookies) response.encoding = response.apparent_encoding
Parsing data
Selector = parsel.Selector (response.text) lis = selector.css ('.list ul li a::attr (href)'). Getall () # print (lis) lis.pop (2) lis.pop (2) # students who want the complete source code can follow my official account: squirrels love cookies # reply to "wallpaper" and get it for free
Save data
Path ='C:\\ Users\\ Administrator\\ Desktop\\ other side\\'+ title + '.jpg' with open (path, mode='wb') as f: f.write (img_url_response.content) print ('{} has been downloaded '.format (title))
Run the code, and the effect is as follows
The above is all the contents of the article "how to climb high-definition 4K desktop wallpaper by Python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!