Python 訪问Google+ (http)
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
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-8-22
@author: guaguastd
@name: search_for_person.py
''' import json #import login
from login import 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)
RESULT:
Input query(None to quit): Tim O'Reilly
[
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/+TimOReilly",
"image": {
"url": "https://lh4.googleusercontent.com/-J8nmMwIhpiA/AAAAAAAAAAI/AAAAAAACoLI/_eGkAvDl1Lg/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/gVEWOJe4zmELXPIOBGB2zJT77YY\"",
"id": "107033731246200681024",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/112971313488103174611",
"image": {
"url": "https://lh4.googleusercontent.com/-DHPPpI53zYs/AAAAAAAAAAI/AAAAAAAAAA0/pMnv4IOHinM/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/-tQMA-kdju1h40Q9yqHvt_XGcI8\"",
"id": "112971313488103174611",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/115665711705516993369",
"image": {
"url": "https://lh3.googleusercontent.com/-ykapO9VSsmU/AAAAAAAAAAI/AAAAAAAAAGE/QjNpGPy5SIc/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/0z-EwRK70ma_SgL89TnXDnNCeg4\"",
"id": "115665711705516993369",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "TIM O'REILLY",
"url": "https://plus.google.com/112630513029834463088",
"image": {
"url": "https://lh3.googleusercontent.com/-dOC3TnU5LJk/AAAAAAAAAAI/AAAAAAAACXA/zxEC3Q2samc/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/kcitEq1pVj3GQMicyWbxqUM9vXc\"",
"id": "112630513029834463088",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/117480952841562724952",
"image": {
"url": "https://lh6.googleusercontent.com/-bpWGUQXAWg0/AAAAAAAAAAI/AAAAAAAAAIs/fCBaH6ldLXU/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/fbrFj4lJ_cpWx9pUUmO6476cZtY\"",
"id": "117480952841562724952",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/103336854217201973281",
"image": {
"url": "https://lh4.googleusercontent.com/-J3iV2F3ex4E/AAAAAAAAAAI/AAAAAAAAAIA/DJKY_V0epG8/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/0dlnI0n2qoODg63r8NG6Xobol8I\"",
"id": "103336854217201973281",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/102467783732787713430",
"image": {
"url": "https://lh4.googleusercontent.com/-P2nQYJTUZY8/AAAAAAAAAAI/AAAAAAAAAAA/b1obv1Rgmg4/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/H3_JCPzhKdR_ZptxJRHGswnL018\"",
"id": "102467783732787713430",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/+TimothyOReilly",
"image": {
"url": "https://lh3.googleusercontent.com/-TdJsE6Qsxzg/AAAAAAAAAAI/AAAAAAAAAis/4ltdyyk61mQ/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/3744uM_v9M6mz9icJoOhqz08cPs\"",
"id": "107415629896108700526",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/106492472890341598734",
"image": {
"url": "https://lh3.googleusercontent.com/-S5DUz4QdL4k/AAAAAAAAAAI/AAAAAAAAAMU/_MARUPifxP4/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/3mHGPwEpTqJTOYMLD8ZTGXAFHxE\"",
"id": "106492472890341598734",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/104189405442379396369",
"image": {
"url": "https://lh4.googleusercontent.com/-JY0W6EiqN6k/AAAAAAAAAAI/AAAAAAAAD8I/ecdZSHwsiQk/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/YxUJ7XitqA_et4VyLmje5-UZbGM\"",
"id": "104189405442379396369",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/106680419484587025186",
"image": {
"url": "https://lh3.googleusercontent.com/-5wQu1d4wF2w/AAAAAAAAAAI/AAAAAAAAAKA/OqGwRWaeVFI/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/-a3tNtNGvyUhChUVfGHHROC16Zo\"",
"id": "106680419484587025186",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "TIM O'REILLY",
"url": "https://plus.google.com/110160587587635791009",
"image": {
"url": "https://lh4.googleusercontent.com/-gWq9vr_JEnc/AAAAAAAAAAI/AAAAAAAAADI/zwCXKP4QeiU/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/ofg-30rIv-rKw7XTBBnDA1i3I_Y\"",
"id": "110160587587635791009",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/116668755775044955466",
"image": {
"url": "https://lh5.googleusercontent.com/-vp_eOqn1RDo/AAAAAAAAAAI/AAAAAAAAAGw/kLYoiV8nPeY/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/ACiNfQOxMSKzzyGcb5jM5bmxl6I\"",
"id": "116668755775044955466",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/107786179585502589799",
"image": {
"url": "https://lh6.googleusercontent.com/-VyqOCKcFBVg/AAAAAAAAAAI/AAAAAAAAACg/ccaDhAaSOrk/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/Dli96fXA5CodkDI-t66PRnrQFJU\"",
"id": "107786179585502589799",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/102994447097932477991",
"image": {
"url": "https://lh6.googleusercontent.com/-AN65SwKBkAA/AAAAAAAAAAI/AAAAAAAAAFI/oYk5S6oRSRM/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/ZGOPPF5KIorb7COpKZ97WBd0bNc\"",
"id": "102994447097932477991",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/103354252176309484961",
"image": {
"url": "https://lh5.googleusercontent.com/-_isKE1mWRt0/AAAAAAAAAAI/AAAAAAAAABM/36dDkRiYvBk/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/GR12dQs7rTeDOnnHnSZOHFC42Ao\"",
"id": "103354252176309484961",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/110507132467773975582",
"image": {
"url": "https://lh5.googleusercontent.com/-tDB-zaAAuD0/AAAAAAAAAAI/AAAAAAAAACY/48R4BFSJ-XQ/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/rgBrNe4FFc6FOl45g_dcf8Cx5ag\"",
"id": "110507132467773975582",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/114402115097637564691",
"image": {
"url": "https://lh5.googleusercontent.com/-ur8ek-VIzeE/AAAAAAAAAAI/AAAAAAAAAMw/JboA3pGeGM4/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/UIRX0od1spatTgp8b_Et5uyxpXM\"",
"id": "114402115097637564691",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/100454277852249756307",
"image": {
"url": "https://lh6.googleusercontent.com/-wYYn4xPXt-s/AAAAAAAAAAI/AAAAAAAAACQ/rXE2GVPnCTM/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/JIKcTr6TRO2TcSlLy6jl_kZ68yA\"",
"id": "100454277852249756307",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/103096937174083026967",
"image": {
"url": "https://lh3.googleusercontent.com/-gVHQA9qDFQ4/AAAAAAAAAAI/AAAAAAAAAAA/wEAfdMcxEX4/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/JupbCFJJqLSOZYsnRCbDMibJ308\"",
"id": "103096937174083026967",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Tim O'Reilly",
"url": "https://plus.google.com/114172069562252200235",
"image": {
"url": "https://lh5.googleusercontent.com/-3xPm1RmotzY/AAAAAAAAAAI/AAAAAAAAAC0/_Ue0ROpAMJk/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/mgTUB4vuFDnN35OV-TfovLuk42c\"",
"id": "114172069562252200235",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/101557961285050424605",
"image": {
"url": "https://lh5.googleusercontent.com/-lTaqhOsfcxw/AAAAAAAAAAI/AAAAAAAAEHM/FLiBXUD0-bk/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/cfMaCQrodj65T59aCWRTZDG1XGU\"",
"id": "101557961285050424605",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/113556773460517050463",
"image": {
"url": "https://lh6.googleusercontent.com/-u22u7FNC4Ak/AAAAAAAAAAI/AAAAAAAAAHE/LjpQ7kqjL2g/photo.jpg? sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/CGEFZv3-qj3jyGLoz4x7MCBUsp4\"",
"id": "113556773460517050463",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/109370454456340755312",
"image": {
"url": "https://lh4.googleusercontent.com/-5WtmN0-NptY/AAAAAAAAAAI/AAAAAAAAABM/UrEmKNnkczk/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/kvne_6PcngEbH44gXZT5c5_aewc\"",
"id": "109370454456340755312",
"objectType": "person"
},
{
"kind": "plus#person",
"displayName": "Timothy O'Reilly",
"url": "https://plus.google.com/106943606032560183935",
"image": {
"url": "https://lh3.googleusercontent.com/-W6NwjvPOcR8/AAAAAAAAAAI/AAAAAAAAABM/2dcYJDcixcQ/photo.jpg?sz=50"
},
"etag": "\"pNz5TVTpPz2Rn5Xw8UrubkkbOJ0/WYHhEYNT2FuI9bHkE_5ZyhwF7Q0\"",
"id": "106943606032560183935",
"objectType": "person"
}
]
Input query(None to quit):
Python 訪问Google+ (http)的更多相关文章
- python訪问redis
python訪问redis 1 Linux上安装redis a) 下载 $ wget http://download.redis.io/releases/redis-3.0.5.tar.gz b) 编 ...
- 搜索学术论文訪问google的能用的几个IP地址
google搜索引擎打不开时的解决的方法,谷歌(google)的IP是多少? google IP镜像. 这里搜集了几个经过測试可用的IP,用来在不能域名訪问google的时候进行訪问 更新一个最新的. ...
- 用上Google才是正事 分享几个訪问Google的IP和域名
通过VPN或者GAE等代理进行訪问,GAE下载请移步<GAE 3.1.18 最新版本号下载 用上Google才是正事>.这是大家通经常使用的办法.也有同学们不愿意使用代理软件.那今天来分享 ...
- python 訪问webservice
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255) ...
- Python 訪问 LinkedIn (API)
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-16 @author: guaguastd @name: l ...
- [Python爬虫] Selenium自己主动訪问Firefox和Chrome并实现搜索截图
前两篇文章介绍了安装.此篇文章算是一个简单的进阶应用吧.它是在Windows下通过Selenium+Python实现自己主动訪问Firefox和Chrome并实现搜索截图的功能. [Python爬虫] ...
- Kivy A to Z -- 怎样从python代码中直接訪问Android的Service
在Kivy中,通过pyjnius扩展能够间接调用Java代码,而pyjnius利用的是Java的反射机制.可是在Python对象和Java对象中转来转去总让人感觉到十分别扭.好在android提供了b ...
- python文件和文件夹訪问File and Directory Access
http://blog.csdn.net/pipisorry/article/details/47907589 os.path - Common pathname manipulations 都是和路 ...
- Linux 终端訪问 FTP 及 上传下载 文件
今天同事问我一个问题,在Linux 下訪问FTP,并将文件上传上去. 我之前一直是用WinSCP工具的. 先将文件从linux copy到windows下,然后在传到ftp上. google 一下. ...
随机推荐
- htmlayout做的虎鲸宝宝
昨天在auto论坛上偶遇一哥们作的虎鲸宝宝例子,尽管作者提供了auto的源码… … 一个C++老农的悲哀.不过大概看了下流程,最后想想:选什么样的语言已经不重要了. 最重要的是里边的资源文件可以拿来耍 ...
- c#实现验证码功能(多种模式下分别实现验证功能)详细,带注释
网上找了很多验证相关的代码,发现有很多瑕疵.现在本人整理测试了一个实现验证码功能的代码,里面有纯数字,纯英文,英文和数字混合等三种模式.并且在必要地方都已经备有注释,希望可以帮到那些需要的人. 验证码 ...
- windows下npm默认的全局路径
C:\Users\用户名\AppData\Roaming\npm\node_modules
- loadrunner运行乱码解决方法
最近进行项目压力测试,选择用loadrunner来进行测试,当在回放时间,脚本中的中文由乱码.快照,经研究,经过一下3步可以解决,分享一下 第一步:当在进行新建脚本时间,选择选项中-〉高级-〉选择“支 ...
- eclipse下java中凝视字体太小和xml中中文字体太小问题解决方法
我们在win7下进行android应用开发.须要搭建对应的开发环境.如今普遍基本上都是eclipse+adt+sdk,在本人搭建完环境后,发现eclipse下.java中的凝视和xml中的中文字体变得 ...
- Redis学习(6)-常用命令
List命令 value值为LinkedList类型. 使用环境: 1,做大数据集合的增删. 2,任务队列.用户任务队列 链表查看 lrange key start end:获取链表从start到en ...
- ELK日志分析平台搭建全过程
一.使用背景 当生产环境有很多服务器.很多业务模块的日志需要每时每刻查看时 二.环境 系统:centos 6.5 JDK:1.8 Elasticsearch-5.0.0 Logstash-5.0.0 ...
- Apache POI – Reading and Writing Excel file in Java
来源于:https://www.mkyong.com/java/apache-poi-reading-and-writing-excel-file-in-java/ In this article, ...
- Ubuntu共享WiFi(AP)给Android方法
更新: 2012-03-03 Android是不支持Ad-hoc模式的WiFi.Windows 7软AP一个还是比较简单的.本文介绍在Ubuntu下实现软AP.(需要你的无线网卡支持AP哈) ...
- 使用Android Ant在编译时混淆
关于ANT 编译和脚本请查看 : http://sinfrancis.javaeye.com/blog/721582 这里使用的是proguard4.4 ,在原有的ANT脚本上加入以下代码: 定义pr ...