【发布时间】:2016-04-17 14:37:13
【问题描述】:
我已经阅读了这个问题 (Python HTML parsing from url),但我还没有理解一些东西。这是代码:
import urllib.request
from html.parser import HTMLParser
# create a subclass and override the handler methods
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
print ("Encountered a start tag:"+ tag)
def handle_endtag(self, tag):
print ("Encountered an end tag :"+ tag)
def handle_data(self, data):
print ("Encountered some data :"+ data)
parser = MyHTMLParser()
info = "http://www.calendario-365.it/js/365.php?page=moon"
response = urllib.request.urlopen(info)
content = response.read()
parser.feed(str(content))
将此代码应用于我的网站给了我这个: http://pastebin.com/m4YV38uM 我想保存到变量中
10,6 乔尼
82%
怎么样?感谢您的回答。 Python版本:3.5。
【问题讨论】:
标签: python html parsing python-3.x