cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
lala
Level VIII

What url you need to log in to and how you can get cookies and download data through JSL login.

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
14 REPLIES 14
lala
Level VIII

Re: What url you need to log in to and how you can get cookies and download data through JSL login.

  • I don't know if cookie in there?

 

Char To Blob(  "~1F~8B~08~00~00~00~00~00~00~03~ABVJ~CEOIU~B2214~D6Q~CA-NW~B2Rz~BEg~D7~D3~0D~13~9FOY~F1~ACc~FB~D3~09~BD~CF:~A6=~ED_~FCd~F7~12%~1D~A5~94~C4~92D%~ABj~A5~E4~C4~82~92~E4~0C 3~AF4'~A7~B6~16~00x&~D1~03E~00~00~00",  "ascii~hex" )

 

lala
Level VIII

Re: What url you need to log in to and how you can get cookies and download data through JSL login.

  • This is true in the browser cookie

 

kbz_newcookie=1; kbzw__user_login=7Obd08_P1ebax9aXwZKsmLCuprCTpYKvpuXK7N_u0ejF1dSeq8WhwtappqDaotqYq8TYqNStwtSapKusy6rNp8euxa-YrqXW2cXS1qCasZypl6iZmLKgzaLOvp_G5OPi2OPDpZalp5OguNnP2Ojs3Jm6y4Ksj6iyk8-wx5eoopWq6dzjx83G2cLc7JCllKunqJ-ZlMKqyq7Do5PkytvGlMDazOTboIK5yenm4N2Qp5miqaOcspyrkKeRr5fG2cfR092oqpywmqqY; kbzw__Session=mnijj070u2h083ms7ouuah9b22; Hm_lvt_164fe01b1433a19b507595a43bf58262=1652962728,1652966374,1653359409,1653375276; Hm_lpvt_164fe01b1433a19b507595a43bf58262=1653375282
Craige_Hales
Super User

Re: What url you need to log in to and how you can get cookies and download data through JSL login.

Yes, I think the website depends on JavaScript for some of its security. I think you'll want to look at the other blog post on using Selenium. That way you can script an existing browser that works from jmp.
Craige
Craige_Hales
Super User

Re: What url you need to log in to and how you can get cookies and download data through JSL login.

And, if you still want to look at it, 1F8B is the gzip signature (because Accept-Encoding said gzip, among others.) You could use

blob=Char To Blob(  "~1F~8B~08~00~00~00~00~00~00~03~ABVJ~CEOIU~B2214~D6Q~CA-NW~B2Rz~BEg~D7~D3~0D~13~9FOY~F1~ACc~FB~D3~09~BD~CF:~A6=~ED_~FCd~F7~12%~1D~A5~94~C4~92D%~ABj~A5~E4~C4~82~92~E4~0C 3~AF4'~A7~B6~16~00x&~D1~03E~00~00~00",  "ascii~hex" );
write(blobtochar(Gzip Uncompress(blob)))
{"code":413,"msg":"缺少用户名或口令","data":{"captcha":null}}

Google Translate: "Missing username or password"

 

But I really think using Selenium might be a better answer. Browser Scripting with Python Selenium  shows how to script login and page through some data, loading it into a data table.

Craige
lala
Level VIII

Re: What url you need to log in to and how you can get cookies and download data through JSL login.

Thank Craige!

I see. So that's it.

Unfortunately, I do not have Python installed on my computer and have not installed Python since USING JMP.

 

From this example alone, it seems that VBA is easier than Python to get cookies for web pages that need to be logged in.

2022-05-24_21-59-30.png