使用 python Django 代码以编程方式登录 Yahoo/MSN(Hotmail) 并获取联系人列表?

发布于 2024-09-26 22:01:31 字数 660 浏览 0 评论 0原文

有没有一种方法可以以编程方式登录 Yahoo!,提供电子邮件 ID 和密码作为输入,并获取用户的联系人?

我在 Gmail 上实现了同样的效果,使用 BeautifulSoup.py

Yahoo 地址簿 API 提供了 BBAuth,这需要将用户重定向到 Yahoo 登录页面。但我正在寻找一种无需重定向即可通过雅虎验证用户身份的方法。 我已经尝试过这个: http://pypi.python.org/pypi/ContactGrabber/0.1

但我得到这个错误:

警告(来自警告模块):文件 “C:\ Python26 \ lib \ site-packages \ contactgrabber-0.1-py2.6.egg \ contactgrabber \ base.py”, 第 31 行

运行时警告:tempnam 对您的程序存在潜在的安全风险

用户名/密码无效

异常WindowsError: (2, '系统找不到该文件 指定', 'C:\DOCUME~1\sjain\LOCALS~1\Temp\2') in >被忽略

Is there a way to programmatically log into Yahoo!, providing email id and password as inputs, and fetch the user's contacts?

I've achieved the same thing with Gmail, using BeautifulSoup.py

Yahoo Address book API provides BBAuth, which requires the user to be redirected to Yahoo login page. But I'm looking for a way to authenticate the user with Yahoo without the redirection.
I have tried this :
http://pypi.python.org/pypi/ContactGrabber/0.1

but I am getting this Error:

Warning (from warnings module): File
"C:\Python26\lib\site-packages\contactgrabber-0.1-py2.6.egg\contactgrabber\base.py",
line 31

RuntimeWarning: tempnam is a potential security risk to your program

Invalid UserID/Password

Exception WindowsError: (2, 'The system cannot find the file
specified', 'C:\DOCUME~1\sjain\LOCALS~1\Temp\2') in > ignored

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧城烟雨 2024-10-03 22:01:31

我通过使用 Urllib 解决了这个问题,代码如下:

LoginUrl = "https://login.yahoo.com/config/login?"
ExportUrl = "http://address.yahoo.com/"

def import_yahoo_contacts(login,passwd):

try :
    form_data = {'login' : login, 'passwd' : passwd}
    jar = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
    form_data = urllib.urlencode(form_data)
    resp = opener.open(LoginUrl, form_data)
    resp = opener.open(ExportUrl)
    page = resp.read()

    index = page.find('InitialContacts')
    startjson = page.index('[',index)
    endjson = page.index(']',index)
    Jsondata = page[startjson:endjson+1]

    user_contacts = []
    data =json.JSONDecoder().decode(Jsondata)
    for r in data:
        userfriends = []
        userfriends.append(r.get('contactName'))
        userfriends.append(r.get('email'))
        user_contacts.append(userfriends)

except:
    return []
return user_contacts 

这对我来说确实有用:)

I solved this problem by using Urllib here is the code :

LoginUrl = "https://login.yahoo.com/config/login?"
ExportUrl = "http://address.yahoo.com/"

def import_yahoo_contacts(login,passwd):

try :
    form_data = {'login' : login, 'passwd' : passwd}
    jar = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
    form_data = urllib.urlencode(form_data)
    resp = opener.open(LoginUrl, form_data)
    resp = opener.open(ExportUrl)
    page = resp.read()

    index = page.find('InitialContacts')
    startjson = page.index('[',index)
    endjson = page.index(']',index)
    Jsondata = page[startjson:endjson+1]

    user_contacts = []
    data =json.JSONDecoder().decode(Jsondata)
    for r in data:
        userfriends = []
        userfriends.append(r.get('contactName'))
        userfriends.append(r.get('email'))
        user_contacts.append(userfriends)

except:
    return []
return user_contacts 

This really work for me :)

滥情空心 2024-10-03 22:01:31

您可以编写一个或仅使用 Pinax。 Pinax 是构建在 Django 之上的工具集合。他们有一个导入联系人信息的应用程序(来自 vCard、Google 或 Yahoo)。

我建议您使用它,因为您不必维护它,并且可以避免重新发明循环。

You could write one or just use Pinax. Pinax is a collection of tools built on top of Django. They have a application which imports contact imfo (from vCard, Google or Yahoo).

I suggest you use this as you don't have to maintain it plus to avoid reinventing the cycle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文