In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces how to use the simplest way to climb the best-looking pictures in Python. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Preface
Next, we have a very basic BeautifulSoup crawler library to write down the process of crawling pictures, download and store pictures, which I believe everyone can understand.
No more nonsense, just go to the code.
Import the library first
Import urllib.requestfrom bs4 import BeautifulSoupimport os
Analyze the website
Url = 'http://www.8she.com/31988.html'res = urllib.request.urlopen (url) html = res.read (). Decode (' utf-8') soup = BeautifulSoup (html, 'html.parser') result = soup.find_all (class_='aligncenter', limit=15) print (result) links = [] for content in result: links.append (content.get (' src'))
Download and save pictures
If not os.path.exists ('D:\\ rieuse\ reptile picture\ photo2'): # create os.makedirs ('D:\\ rieuse\ reptile picture\ photo2') I = 0for link in links: I + = 1 filename ='D:\\ rieuse\ reptile picture\ photo2\'+ 'photo' + str (I) +' .jpg' with open (filename,'w') as file: urllib.request.urlretrieve (link) if the path does not exist Filename) priint ('download Picture:', str (I))
Haha, is it a very simple process of crawling pictures? Welcome to communicate, study together, report mistakes together and make progress together.
About how to use the simplest way to climb the best-looking pictures in Python, so much for sharing here. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.