在不到 6 小时内从 60,000 个 Facebook ID 中提取数据?

发布于 2024-12-27 07:26:09 字数 1332 浏览 0 评论 0原文

我已将所有 Facebook 粉丝的 Faceboojk 个人资料 ID 下载到访问数据库,并编写了一个函数来从 Facebook 图形 API 中提取区域设置数据。以下是图形 api 的示例:-

http://graph.facebook.com/665117534

我的代码循环遍历每条记录并从 API 中提取数据,如下所示:-

    Function fbl(fb_user_id As String) As String
    Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte
    Dim FB_URL As String
    Dim fb_user_data As String

    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")

    FB_URL = "http://graph.facebook.com/" & fb_user_id

    oXMLHTTP.Open "GET", FB_URL, False
    oXMLHTTP.Send

    Do While oXMLHTTP.readyState <> 4
        DoEvents
    Loop

    fb_user_data = oXMLHTTP.responsetext

    n0 = InStr(1, fb_user_data, "locale") '
    If n0 = 0 Then
        locale_code = "PAGE"
    Else
        n00 = InStr(n0, fb_user_data, "}") '
        locale_code = Mid(fb_user_data, n0 + 6, n00 - n0)
        locale_code = Replace(locale_code, """", "")
        locale_code = Replace(locale_code, ",", "")
        locale_code = Replace(locale_code, " ", "")
        locale_code = Mid(locale_code, 5, Len(locale_code) - 6)
    End If

    fbl = locale_code

    Set oXMLHTTP = Nothing

End Function

这工作正常,但测试 100 条记录需要 35 秒,这表明整个表将花费 5.6 小时。有没有更有效、更快速的方法来做到这一点?

谢谢

乔纳森

I have downloaded the Faceboojk profile ID's of all of our Facebook fans to an access databse and have written a function to pull the locale data from the Facebook graph api. Here is an example of the graph api:-

http://graph.facebook.com/665117534

My code loops through each record and pulls teh data from the API like this:-

    Function fbl(fb_user_id As String) As String
    Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte
    Dim FB_URL As String
    Dim fb_user_data As String

    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")

    FB_URL = "http://graph.facebook.com/" & fb_user_id

    oXMLHTTP.Open "GET", FB_URL, False
    oXMLHTTP.Send

    Do While oXMLHTTP.readyState <> 4
        DoEvents
    Loop

    fb_user_data = oXMLHTTP.responsetext

    n0 = InStr(1, fb_user_data, "locale") '
    If n0 = 0 Then
        locale_code = "PAGE"
    Else
        n00 = InStr(n0, fb_user_data, "}") '
        locale_code = Mid(fb_user_data, n0 + 6, n00 - n0)
        locale_code = Replace(locale_code, """", "")
        locale_code = Replace(locale_code, ",", "")
        locale_code = Replace(locale_code, " ", "")
        locale_code = Mid(locale_code, 5, Len(locale_code) - 6)
    End If

    fbl = locale_code

    Set oXMLHTTP = Nothing

End Function

This works fine but testing a 100 records took 35 seconds which suggests that the whole table will take 5.6 hours. Is theire a more efficent, speedier way of doing this?

Thanks

Jonathan

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

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

发布评论

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

评论(1

情痴 2025-01-03 07:26:09

我的方法是使用带有 System.NET.Sockets 和 关闭 Nagle 算法

我还没有看到很多用 VBA 编写的高性能计算应用程序

编辑

由于您使用的是 XMLHTTP 对象,因此您应该重新标记此问题以反映这一点。了解该 API 的人可能会得到更好的回应。

My approach has been to use a multi threaded C# application with System.NET.Sockets and turn off the Nagle Algorithm.

I haven't seen many high performance computing applications written in VBA

Edit

Since you're using the XMLHTTP object you should retag this question to reflect that. You may get a better response from people who know that API.

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