How to get html tags from url?

2019-07-30 01:40发布

问题:

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.