In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use Python to crawl web content", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Python to crawl web content"!
Write execution code
First, you need to install requests and BeautifulSoup4, and then execute the following code. Import requests from bs4 import BeautifulSoup iurl = 'http://news.sina.com.cn/c/nd/2017-08-03/doc-ifyitapp0128744.shtml' res = requests.get (iurl) res.encoding =' utf-8' # print (len (res.text)) soup = BeautifulSoup (res.text) 'html.parser') # title H1 = soup.select (' # artibodyTitle') [0] .text # Source time_source = soup.select ('. Time-source') [0] .text # Source origin = soup.select ('# artibody p') [0] .text.strip () # original title oriTitle = soup.select ('# artibody p') [1] .text.strip () # content raw_content = soup.select ('# artibody p') [2: 19] content = [] for paragraph in raw_content: content.append (paragraph.text.strip ())'@ .join (content) # responsible Editor ae = soup.select ('.article-editor') [0] .text Thank you for your reading The above is the content of "how to use Python to crawl web content". After the study of this article, I believe you have a deeper understanding of how to use Python to crawl web content, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.