首页 > 代码库 > Python 获取Google+特定用户最新动态
Python 获取Google+特定用户最新动态
CODE:
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-28 @author: guaguastd @name: login.py # Request over http def google_login_http(resource_type, action, field): # import requests import requests import re # key information key = '' # base url url = 'https://www.googleapis.com/plus/v1' # build standard field for matStr,repStr in [[" ", "+"], ["'", "%27"]]: reobj = re.compile(matStr) field = reobj.sub(repStr, field) # Build the urls urls = '%s/%s?%s=%s&alt=json&key=%s' % (url, resource_type, action, field, key) #print 'urls: ', urls # Get the content content = requests.get(urls, verify=False).json() # return return content # Build personal google_api # sType: 0 means people; 1 means activities; 2 means comments; 3 means moments def google_api_request(sType, **kwargs): # import requests import requests # key information key = '' # base url url = 'https://www.googleapis.com/plus/v1' # Build the request if sType == 0: pass elif sType == 1: action = kwargs['action'] if action is 'list': collection = kwargs['collection'] userId = kwargs['userId'] if 'maxResults' in kwargs: maxResults = kwargs['maxResults'] else: maxResults = 20 urls = '%s/people/%s/activities/%s?maxResults=%s&key=%s' % (url, userId, collection, maxResults, key) content = requests.get(urls, verify=False).json() return content
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-9-4 @author: guaguastd @name: user_activity_fetch.py ''' import json from login import google_api_request, google_login_http while True: query = raw_input("Input query(None to quit): ") if query.strip() == '': break people_feed = google_login_http("people", "query", query) #people_feed = google_api.people().search(query=query).execute() #print json.dumps(people_feed['items'], indent=1) for user in people_feed['items']: userId = user['id'] activity_feed = google_api_request(1, action='list', collection='public', maxResults='100', userId=userId) print json.dumps(activity_feed, indent=1)
RESULT:
"content": "I read Brad Stone's history of Amazon, <i>The Everything Store</i>, \u00a0over the holidays, and recommend it highly. \u00a0To be sure, it is incomplete and doubtless has many inaccuracies, but it gives insight into the mind of a remarkable man and the company he has built - a company with profound influence on the present and future shape of our society.<br /><br />I had heard scuttlebutt that the book was hostile to Amazon. \u00a0I didn't find that to be the case at all. In fact, it increased my admiration for Jeff and what he and his team have accomplished.<br /><br />After Steve Jobs died, everyone was saying "Will we ever see his like again?" \u00a0I would always respond, "What do you mean? \u00a0He's already here, and his name is Jeff Bezos. \u00a0He's the only other tech entrepreneur I know who has transformed multiple industries, and shown the ability to work his magic not once but many times. \u00a0He's been the misunderstood underdog who came out on top because of vision, passion, and persistence."<br /><br />(OK, since then, Elon Musk has shown signs of pulling off the same ambition. But the fact remains that Jeff is one of the most important and successful entrepreneurs of our time.)<br /><br />Because of my admiration and liking for Jeff, \u00a0I was a bit dismayed to see the book position me as an "adversary." \u00a0While in some ways I am a competitor to Amazon, I think of myself more as a partner and friend than any kind of adversary! \u00a0And while Jeff and I have occasionally butted heads, first about the 1-click patent back in 2000 (a conflict that ended up with us as friends), and later about some of Amazon's overly aggressive business tactics towards suppliers (described in chapter 10 of the book), and about the use of a proprietary DRM'd ebook format rather than open standards for the Kindle, I have always been a huge fan.<br /><br />One of the things the book gets across is what a great <b>learner</b> Jeff is. It makes clear just how freshly he responded to the challenges of growing his business, relying on some uncompromising principles but also adapting them so that, as long-time Amazon employee Rick Dalzell described, he always engaged his decision-making around "the best truth at the time." (Chapter 9, page 267) His intense curiosity is one of the most striking things about him.\u00a0<br /><br />The book also underplays Jeff's humanity, humor, and kindness. There are a lot of stories of how forceful, even abrasive, he sometimes is with subordinates - and I imagine that can be unpleasant. \u00a0But I also know just how hard it is to get thousands of people moving in the same direction without ruffling any feathers. And some of the changes that Jeff had to make to the company direction required enormous determination and force. I wish that some other leaders I know (e.g. in government) had equal clarity and determination.<br /><br />The book also really helped me see how deep Jeff's focus on the customer is. While I have always believed that focus to be sincere, I have also always worried that it would fade as the company became dominant, as is so often the case. \u00a0But the book makes clear again and again how it really is a touchstone for Jeff.<br /><br />I have also worried that focus on the customer isn't enough - that companies that become as powerful as Amazon also need to understand the complete ecosystem in which they operate. \u00a0The book's account of Amazon's sometimes brutal interactions with companies that it wanted to acquire, like Quidsi, the company behind <a href=http://www.mamicode.com/"http://diapers.com/">diapers.com (page 298), and suppliers like German knife-maker Wusthof (page 300 and ff) makes clear that Amazon hasn't fully learned that lesson, and seems to believe that as long as customers benefit, it's ok to hurt suppliers. Sometimes that is true, when suppliers are inefficient or exploitive of their customers, but in other cases, squeezing all the profit out of suppliers' businesses is enormously short sighted. /u00a0The ideal ecosystem is one where everyone flourishes, not where one company flourishes at the expense of all the others.
But I got a lot of hope from reading about Jeff's "Amazon.love memo" (Chapter 10, page 317-318), in which he analyzed why some big and powerful companies are hated, while others continue to engender love from not only their customers but their entire ecosystem. /u00a0In particular, I liked that one of the principles that Jeff distilled was this one:
"Capturing all the value only for the company is not cool."
I've long urged companies to make "Create more value than you capture" their watchword, because it seems to me that building a healthy ecosystem in which everyone - employees, customers, suppliers, partners, and even competitors - can flourish is key to the positive impact that capitalism can have on society as a whole. /u00a0(See http://radar.oreilly.com/2009/01/work-on-stuff-that-matters-fir.html)
The fact that Jeff is thinking about this as Amazon gets more dominant is a really good sign. /u00a0Some companies never realize that they need to be especially careful to create value for everyone as they get larger and more powerful./u00a0
My chief beef about the book is that it skimped on some of the really big management lessons from Amazon. For me one of the most fascinating things about Amazon is the way that it seems to have modeled its organizational culture on its software. Stories I've heard about the way small teams are organized at Amazon remind me of the way modern modular software is designed. /u00a0I suspect that Amazon has cracked the code of the problem that was once laid out to me by the CIO of Fidelity Investments: /u00a0"We know about all these new technologies. What we don't know is how to organize our company around them." /u00a0
In addition, I wish there were more written about the design of Amazon's internal services. When Jeff had the insight that led to the rise of Amazon as a platform - not only that its software needed to make the transition from a single monolithic application to a series of reusable web services, but also that those services should be designed in such a way that they could be re-used as easily by developers outside the company as by its internal units - he demonstrated a lesson that has yet to be learned by most large organizations.
Take the recent healthcare.gov debacle. /u00a0One of the functions that the system depends on is income verification by the IRS. That lookup is, consistent with monolithic old-school software development, a tightly integrated part of the application rather than a true reusable service. If healthcare.gov were designed with the lessons of Amazon in mind, not only could the Federal healthcare.gov site call IRS web services to do income verification, but so could any of the state healthcare exchanges, or, for that matter, any private insurance company - or any company that needed to do income verification for any purpose.
I realize that this is a general business book, and getting too deep on the technology might have scared off many readers, but I do hope that some future book about Amazon will give more than tantalizing glimpses of the interplay between the software architecture of a large-scale web enterprise like Amazon and the human and organizational architecture /u00a0that makes it possible for that software to be deployed in as agile a way as possible.
I highly recommend this book. Amazon is one of the most important companies in the 21st century economy, and anyone whose business has been or will be touched by Amazon should be sure to read it./ufeff", >Python 获取Google+特定用户最新动态
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。