USGA-GHIN第二页信息-XML登录后从第二个网页获取信息 [英] USGA - GHIN 2nd Page Information - Get The Info from a 2nd web page after an XML log in

查看:37
本文介绍了USGA-GHIN第二页信息-XML登录后从第二个网页获取信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从"asmitu"那里获得了出色的帮助,他用以下代码帮助我登录了USGA GHIN网站.但是,我真正的最终问题是登录并操纵到该第二个URL(" https://www.ghin.com/golfer-lookup/following )提取存储在第二个URL页面上的我的数据.有没有办法修改下面的代码,以便登录后进入第二页?

I got excellent help from "asmitu" who helped me log-in to the USGA GHIN site with the following code. However, my real end problem was to log-In and then maneuver to this 2nd URL ("https://www.ghin.com/golfer-lookup/following") to extract my data that is stored on the 2nd URL page. Is there a way to modify the code below so that I land on the 2nd page after login?

Sub GHIN_Login()

Const Url = "https://api2.ghin.com/api/v1/public/login.json?"
Dim Http As New XMLHTTP60, ghinNum$, lastName$

ghinNum = ""            'put your ghinNum here
lastName = ""           'put your lastName here

With Http
  .Open "GET", Url & "ghinNumber=" & ghinNum & "&lastName=" & lastName & "&remember_me=false", False
  .setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
  .setRequestHeader "Referer", "https://www.ghin.com/login"
  .send
End With

MsgBox Http.responseText
End Sub

推荐答案

该目标页面的内容是动态生成的,因此您无法使用xhr解析必填字段.但是,以下尝试将导致您抓取其中包含必填字段的json响应.

The content of that target page generates dynamically, so you can't parse the required fields using xhr. However, the following attempt should lead you grab the json response having required fields within it.

Sub GetInformation()
    Const Url = "https://api2.ghin.com/api/v1/public/login.json?"
    Const Link = "https://api2.ghin.com/api/v1/followed_golfers/"
    Dim Http As New XMLHTTP60, ghinNum$, lastName$

    ghinNum = ""
    lastName = ""

    With Http
        .Open "GET", Url & "ghinNumber=" & ghinNum & "&lastName=" & lastName & "&remember_me=false", False
        .setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
        .setRequestHeader "Referer", "https://www.ghin.com/login"
        .send
        .Open "GET", Link & ghinNum & ".json", False
        .send
    End With

    MsgBox Http.responseText
End Sub

这篇关于USGA-GHIN第二页信息-XML登录后从第二个网页获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆