2016年7月18日 星期一

如何使用Python 套件: BeautifulSoup4 剖析網頁內容?

Ref :  http://www.largitdata.com/course/8/


from bs4 import BeautifulSoup
html_sample = ' \
<html> \
 <body> \
   <h1 id="title">Hello World</h1> \
   <a href="#" class="link">This is link1</a> \
   <a href="# link2" class="link">This is link2</a> \
 </body> \
</html>'

soup = BeautifulSoup(html_sample,"html.parser")
#print soup.text
print soup.contents




print soup.select("html")


print soup.select(")

沒有留言:

張貼留言