下面给出了代码,这是在一周前工作,现在它不起作用。这是我的项目。请帮助
#!/usr/bin/python2
# -*-coding:utf-8-*-
import re
import urllib
url = 'http://twitaholic.com/'
id = '@(.*)<br />'
id_re = re.compile(id)
res = urllib.urlopen(url)
data = res.read()
id_info = id_re.findall(data)
f = open('result.txt', 'w+')
for item in id_info:
print (item)
f.write(item + '\n')
这是错误
Traceback (most recent call last):
File "D:\Main Project\April 5
negation_intensifiers_sentiwordNet\TwitterRank_SentiCircle\GetTopTwitters.py", line 11, in <module>
res = urllib2.urlopen(url)
File "C:\Python27\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 435, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python27\lib\urllib2.py", line 473, in error
return self._call_chain(*args)
File "C:\Python27\lib\urllib2.py", line 407, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
有人请帮忙