Mechanize と Beautiful スープを使用して、Delicious からデータを取得しています
from mechanize import Browser
from BeautifulSoup import BeautifulSoup
mech = Browser()
url = "http://www.delicious.com/varunsrin"
page = mech.open(url)
html = page.read()
soup = BeautifulSoup(html)
print soup.prettify()
これは、私が投げたほとんどのサイトで機能しますが、Delicious では次の出力で失敗します
Traceback (most recent call last):
File "C:\Users\Varun\Desktop\Python-3.py",
line 7, in <module>
page = mech.open(url)
File "C:\Python26\lib\site-packages\mechanize\_mechanize.py",
line 203, in open
return self._mech_open(url, data, timeout=timeout) File
"C:\Python26\lib\site-packages\mechanize\_mechanize.py",
line 255, in _mech_open
raise response httperror_seek_wrapper: HTTP Error
403: request disallowed by robots.txt
C:\Program Files (x86)\ActiveState Komodo IDE 6\lib\support\dbgp\pythonlib\dbgp\client.py:1360:
DeprecationWarning:
BaseException.message has been deprecated as of Python 2.6
child = getattr(self.value, childStr)
C:\Program Files (x86)\ActiveState Komodo IDE 6\lib\support\dbgp\pythonlib\dbgp\client.py:456:
DeprecationWarning:
BaseException.message has been deprecated as of Python 2.6
return apply(func, args)