我正在尝试制作一个简单的 Twitter Bot,如果他们的推文包含某个主题标签,它会转发用户
所以对于我的搜索网址,我有以下内容:
http://search.twitter.com/search.json?q=address&count=1
但是每当我运行我的程序时,我只会得到 1 条推文及其信息。我很困惑为什么我只得到 1 条推文而不是 10 条。即使我改变“count”参数的值,我也会得到 1 条推文。
如果我更改搜索 url 以将“hashtags”替换为“q”,我会收到一堆错误:
http://search.twitter.com/search.json?hashtags=151milford&count=10
上面的那一行给了我以下错误
File "C:\Users\Documents\pythonbot.py", line 16, in <module>
o = urllib2.urlopen(url) #open the url
File "C:\PYTHON27\LIB\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "C:\PYTHON27\LIB\urllib2.py", line 406, in open
response = meth(req, response)
File "C:\PYTHON27\LIB\urllib2.py", line 519, in http_response
'http', request, response, code, msg, hdrs)
File "C:\PYTHON27\LIB\urllib2.py", line 444, in error
return self._call_chain(*args)
File "C:\PYTHON27\LIB\urllib2.py", line 378, in _call_chain
result = func(*args)
File "C:\PYTHON27\LIB\urllib2.py", line 527, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
我仍在尝试学习如何使用 API,所以任何提示都会很棒