# apt-get install python-feedparser
# python
Python 2.5.2 (r252:60911, Jul 12 2008, 12:02:40)
[GCC 4.3.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import feedparser
>>> d = feedparser.parse('')
>>> d.encoding
'windows-1252'
>>> d.status
200
>>> d = feedparser.parse('http://control.cublog.cn')
>>> d.encoding
'GB2312'
>>> d.status
302
>>> d.href
'http://control.cublog.cn/login.php?back=index.php'
>>> d = feedparser.parse('')
>>> d.encoding
'UTF-8'
>>> d.status
301
>>> d = feedparser.parse('')
>>> d.encoding
'EUC-KR'
>>> d = feedparser.parse('')
>>> d.encoding
'ISO-8859-1'
>>> d.headers
{'content-language': 'en', 'transfer-encoding': 'chunked', 'accept-ranges': 'bytes', 'expires': 'Sun, 03 Aug 2008 19:05:00 GMT', 'server': 'Apache', 'connection': 'close', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'date': 'Sun, 03 Aug 2008 19:04:00 GMT', 'content-type': 'text/html; charset=ISO-8859-1'}
阅读(1807) | 评论(0) | 转发(0) |