【发布时间】:2012-02-20 18:15:27
【问题描述】:
我是网络编程新手。我想用 Python 构建一个爬虫来爬取 Foursquare 中的社交图。
通过使用apiv2 库,我有一个“手动”控制的爬虫。主要方法是这样的:
def main():
CODE = "******"
url = "https://foursquare.com/oauth2/authenticate?client_id=****&response_type=code&redirect_uri=****"
key = "***"
secret = "****"
re_uri = "***"
auth = apiv2.FSAuthenticator(key, secret, re_uri)
auth.set_token(code)
finder = apiv2.UserFinder(auth)
#DO SOME REQUIRES By USING THE FINDER
finder.finde(ANY_USER_ID).mayorships()
bla bla bla
问题是,目前我必须在浏览器中输入 URL 并从重定向 URL 中提取 CODE,然后在我的程序中更新 CODE,然后再次运行。我认为可能有某种方法可以将 CODE 编码到我当前的程序中并使其自动化。
感谢任何说明或示例代码。
【问题讨论】:
标签: python api oauth-2.0 web-crawler foursquare