This article mainly introduces the Python 3 using BeautifulSoup Fetch P tag method, the text gives the detailed sample code for everyone to reference the study, to everyone has a certain reference learning value, needs of friends below to see together.
Objective
This article is mainly about Python 3 with BeautifulSoup Fetch p Tag Method example, share out for everyone to refer to the study, below to see the detailed introduction:
Example code:
#-*-Coding:utf-8-*-#python 2.7#xiaodeng#http://tieba.baidu.com/p/2460150866# label operation from BS4 Import Beautifulsoupimport Urllib.requestimport re# If it is a URL, you can use this method to read the page #html_doc = "http://tieba.baidu.com/p/2460150866" # req = Urllib.request.Request (html_doc) #webpage = Urllib.request.urlopen (req) #html = Webpage.read () html= "" "
"Recommended"
1. Python uses BeautifulSoup to implement crawlers
2. Using Python to implement asynchronous agent crawler and Agent pool method
3. A detailed description of Python crawler using proxy proxies crawl Web page method