CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on 2014-9-5
@author: guaguastd
@name: html_to_text.py
'''
from login import google_api_request
from html import cleanHtml
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)
people_feed = google_api_request(0, action='search', query=query)
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)
print '\nPrimary content including HTML tag:'
print activity_feed['items'][0]['object']['content']
print '\nConverted content without HTML tag:'
print cleanHtml(activity_feed['items'][0]['object']['content'])
RESULT:
Input query(None to quit): Tim O'Reilly
Primary content including HTML tag:
ABC World News covers @HomeDepot credit card data breach, recommends @BillGuard to protect yourself! BillGuard on ABC World News Tonight With David Muir … (Minute 1:25)
Converted content without HTML tag:
ABC World News covers @HomeDepot credit card data breach, recommends @BillGuard to protect yourself! BillGuard on ABC World News Tonight With David Muir … (Minute 1:25 )