Hello everyone!
This site requires cookies to download the complete data. How do I get cookies and download data through JSL login?
Thanks!
VBA
Sub Post()
Dim User_agent, Response_Text, username, password, cookie, json
username = [d1]: password = [f1]
User_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36"
Post_data = "return_url=https%3A%2F%2Fwww.jisilu.cn%2Fdata%2Fcbnew%2F&user_name=" & jslencode(username) & "&password=" & jslencode(password) & "&aes=1&auto_login=0"
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "get", "https://www.jisilu.cn/login/", False
.setrequestheader "User-Agent", User_agent
.send
.Open "post", "https://www.jisilu.cn/webapi/account/login_process/", False
.setrequestheader "User-Agent", User_agent
.setrequestheader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
.send (Post_data)
cookie = Split(.getallresponseheaders, "Set-Cookie: ")(2)
.Open "get", "https://www.jisilu.cn/data/cbnew/detail_hist/" & ([b1] & ""), False
.setrequestheader "User-Agent", User_agent
.setrequestheader "cookie", cookie
.send "fprice=&tprice=&curr_iss_amt=&volume=&svolume=&premium_rt=&ytm_rt=&rating_cd=&is_search=N&market_cd%5B%5D=shmb&market_cd%5B%5D=shkc&market_cd%5B%5D=szmb&market_cd%5B%5D=szcy&btype=&listed=Y&qflag=N&sw_cd=&bond_ids=&rp=50&page=1"
Response_Text = .responsetext
Set json = JsonConverter.ParseJson(Response_Text)
End With
End Sub