问题
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