cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
lwx228
Level VIII

How to use JSL form of "POST" WEB data?

After I learned to use JMP to download web page data, ga mother likes to use JMP to download web page data now, but it is more difficult to process the web page of POST.

 

Get expert help: how to download data using JSL in the following way:

 

2019-11-20_18-58.png

POST http://listxbrl.sse.com.cn/companyInfo/showBalance.do HTTP/1.1
Host: listxbrl.sse.com.cn
Connection: keep-alive
Content-Length: 54
Accept: */*
Origin: http://listxbrl.sse.com.cn
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://listxbrl.sse.com.cn/companyInfo/toCompanyInfo.do?stock_id=600007&report_period_id=5000

report_year=2018&stock_id=600007&report_period_id=5000

I can do it with VBA.

 

Thanks!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Ryan_Gilmore
Community Manager Community Manager

Re: How to use JSL form of "POST" WEB data?

These lines of code,

 

query = Associative Array();
query["report_year"] = 2018;
query["stock_id"] = 600007;
query["report_period_id"] = 5000;

are used to construct the query parameter list in the URL, e.g.

 

report_year=2018&stock_id=600007&report_period_id=5000

 

In the original code I supplied, the code had

 

query["period_id"] = 5000;

which would have given an incorrect query parameter list of

 

report_year=2018&stock_id=600007&period_id=5000

View solution in original post

Re: How to use JSL form of "POST" WEB data?

Using example in the thread, you'd want something like:

query = Associative Array();
query["report_year"] = 2018;
query["stock_id"] = 600007;
query["period_id"] = 5000;

request = HTTP Request(
	Url( "http://listxbrl.sse.com.cn/companyInfo/showBalance.do" ),
	Method( "POST" ),
	Form( Fields(query) )
);

request << Send;

The Form message has been there since the beginning.

It has Fields and Files sub parts to it. Both are associative arrays.

In the "Fields" case it's name/value pairs where the value can be either character or a List of characters.

In the "Files" case it's name/value pairs where the value can be either filename or a List of filenames.

If only "Fields" is used, then the request header is automatically set to application/x-www-form-urlencoded

If "Fields" and "Files" (or just "Files") is used, then the request header is automatically set to multipart/form-data.

I'll update the thread with this information, too.

View solution in original post

14 REPLIES 14
lwx228
Level VIII

Re: How to use JSL form of "POST" WEB data?

I searched for-
Method("POST")
in the help file 、but found no similar code.
lwx228
Level VIII

Re: How to use JSL form of "POST" WEB data?

Below is the VBA code, can be downloaded to get the page data.
But I still haven't been able to convert it into JSL code.

2019-11-21_13-08.png
Please give me help.Thank you very much!

 

VBA:

Sub Main()
    Dim strText As String
    With CreateObject("MSXML2.XMLHTTP")
        .Open "POST", "http://listxbrl.sse.com.cn/companyInfo/showBalance.do", False
        .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        .Send "report_year=2018&stock_id=600007&report_period_id=5000"
        strText = .responsetext
        Debug.Print strText
    End With
    Cells(1, 1) = strText
End Sub

 

 

 

Ryan_Gilmore
Community Manager Community Manager

Re: How to use JSL form of "POST" WEB data?

I think the following might be close to what you need,

 

request_headers = Associative Array();
request_headers["Content-type"] = "application/x-www-form-urlencoded";
	
query = Associative Array();
query["report_year"] = 2018;
query["stock_id"] = 600007;
query["period_id"] = 5000;

request = HTTP Request(
	Url( "http://listxbrl.sse.com.cn/companyInfo/showBalance.do" ),
	Method( "POST" ),
	Headers( request_headers ),
	QueryString( query )
);
lwx228
Level VIII

Re: How to use JSL form of "POST" WEB data?

Thank Ryan_Gilmore !

 

This approach still hasn't worked.

It seems that this form of POST method, JMP application is not yet.

2019-11-22_08-03.png

 

 

Ryan_Gilmore
Community Manager Community Manager

Re: How to use JSL form of "POST" WEB data?

Once the request has been created. you then need to issue the Send command, e.g.

 

data = request << Send;
If( request << IsSuccess,
    json_data = Parse JSON( data );
);
lwx228
Level VIII

Re: How to use JSL form of "POST" WEB data?

My knowledge of the JMP approach is limited.
I can only imitate.Still no results.

 

2019-11-23_08-01.png


Thank Ryan_Gilmore!

lwx228
Level VIII

Re: How to use JSL form of "POST" WEB data?

get "DATA" of theta:

" <!DOCTYPE html PUBLIC \!"-//W3C//DTD XHTML 1.0 Transitional//EN\!" \!"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\!"> <html xmlns=\!"http://www.w3.org/1999/xhtml\!"> <head> <meta http-equiv=\!"Content-Type\!" content=\!"text/html; charset=utf-8\!" />
……
</p> </body> </html> "
Ryan_Gilmore
Community Manager Community Manager

Re: How to use JSL form of "POST" WEB data?

I notice that one of the parameters is incorrect. The code I suggested had "period_id" rather than "report_period_id" as shown in your original post. It's possible that may be contributing to the "500 Internal Server Error" message.

lwx228
Level VIII

Re: How to use JSL form of "POST" WEB data?

I SEE.

2019-11-25_22-16.png