How to get html tags from url?

时光怂恿深爱的人放手 提交于 2019-12-24 14:47:54

问题


How would you get all the HTML tags from a URL and print them?


回答1:


import urllib
print urllib.urlopen('http://www.example.com/blah').read()



回答2:


Fetch it (using mechanize, urllib or whatever else you want), parse what you get (using elementtree, BeautifulSoup, lxml or whatever else you want) and you have what you want.



来源:https://stackoverflow.com/questions/4435882/how-to-get-html-tags-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!