In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to climb Bing wallpaper by Python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Preface
A person who likes to toss around, seeing that there is only one kind of wallpaper on the table for a long time, wants to crawl some wallpaper from the Internet, save it, and switch wallpaper at random.
Tools
Python3 + requests + re
Fiddler bag grabbing tool.
Then you can be sure that the url of the picture must be in the web source code.
We can see the picture we want url in the source code.
It can be grasped by regularization.
Import requestsimport threadingimport jsonimport refrom pprintimport pprintimport timeclass Bing: def _ init__ (self): self.url = "https://bing.ioliu.cn/?p={}" self.headers = {" User-Agent ":" Mozilla/5.0 (Windows NT 10.0; Win64) X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 "} def parse_url (self, url): print (" * "* 20) response = requests.get (url, headers=self.headers) return response.content def regular_img_name (self) Img_url): ret = re.findall (r "http://h2.ioliu.cn/bing/(.*?)\.(.*?)$", img_url, re.M | re.S) print (ret) return ret def download_imgs (self) Img_list): for url in img_list: img = self.parse_url (url) time.sleep (1) strs = self.regular_img_name (url) with open (". / bing/ {}. {}" .format (strs [0] [0], strs [0] [1]) "wb") as f: f.write (img) print ("{} success" .format (url)) def regular_img_url (self, html_str): ret = re.findall (r ". *? pic= (. *?)\? imageslim.*?", html_str, re.M | re.S) return ret def run (self): for i in range (1 10): url = self.url.format (I) html_str = self.parse_url (url). Decode () img_list = self.regular_img_url (html_str) print (img_list) self.download_imgs (img_list) if _ name__ = "_ _ main__": bing = Bing () bing.run () That's all for "how Python crawls Bing wallpaper". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.