如何使用JSL形式的“POST”WEB数据?在我学会了用JMP下载网页数据后,ga妈妈现在喜欢用JMP下载网页数据,但是处理POST的网页比较难。
求高手帮助:如何使用JSL下载数据,方法如下:

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
我可以用 VBA 来做。
谢谢!
Re: 如何使用 JSL 形式的“POST”WEB 数据?感谢高手的帮助,让我学到了很多技巧,谢谢!Re: 如何使用 JSL 形式的“POST”WEB 数据?在线程中使用示例,你会想要这样的东西:
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;
表单消息从一开始就存在。
它有字段和文件子部分。 两者都是关联数组。
在“字段”的情况下,它是名称/值对,其中值可以是字符或字符列表。
在“文件”的情况下,它是名称/值对,其中值可以是文件名或文件名列表。
如果仅使用“字段”,则请求标头会自动设置为应用程序/x-www-form-urlencoded
如果使用“字段”和“文件”(或仅使用“文件”),则请求标头会自动设置为 multipart/form-data。
我也会用这些信息更新线程。
Re: 如何使用 JSL 形式的“POST”WEB 数据?完美的。
感谢 Ryan_Gilmore!

Re: 如何使用 JSL 形式的“POST”WEB 数据?这些代码行,
query = Associative Array();
query["report_year"] = 2018;
query["stock_id"] = 600007;
query["report_period_id"] = 5000;
用于构造URL中的查询参数列表,例如
report_year=2018&stock_id=600007&report_period_id=5000
在我提供的原始代码中,代码有
query["period_id"] = 5000;
这会给出一个不正确的查询参数列表
report_year=2018&stock_id=600007&period_id=5000
Re: 如何使用 JSL 形式的“POST”WEB 数据?我只是尝试使用原始 VBA,继续使用 ID 5000,并且仍然能够下载。
“report_year=2018&stock_id=600007&report_period_id=5000”
Re: 如何使用 JSL 形式的“POST”WEB 数据?我懂了。

Re: 如何使用 JSL 形式的“POST”WEB 数据?我注意到其中一个参数不正确。 我建议的代码具有“period_id”而不是原始帖子中显示的“report_period_id”。 这可能会导致出现“500 Internal Server Error”消息。
Re: 如何使用 JSL 形式的“POST”WEB 数据?获取 theta 的“数据”:
" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\ !"> http://www.w3.org/1999/xhtml\ !"> <meta http-equiv="\!"Content-Type\!"" content="\!"text/html;字符集=utf-8\!"" />
……
"Re: 如何使用 JSL 形式的“POST”WEB 数据?我对 JMP 方法的了解有限。
我只能模仿。仍然没有结果。

感谢 Ryan_Gilmore!
Re: 如何使用 JSL 形式的“POST”WEB 数据?创建请求后。然后您需要发出发送命令,例如
data = request << Send;
If( request << IsSuccess,
json_data = Parse JSON( data );
);Re: 如何使用 JSL 形式的“POST”WEB 数据?感谢 Ryan_Gilmore !
这种方法仍然没有奏效。
好像这种形式的POST方法,JMP应用还没有。

Re: 如何使用 JSL 形式的“POST”WEB 数据?我认为以下内容可能接近您的需要,
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 )
);
Re: 如何使用 JSL 形式的“POST”WEB 数据?下面是VBA代码,可以下载获取页面数据。
但是我还是没能把它转换成 JSL 代码。

请给我帮助。非常感谢!
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
Re: 如何使用 JSL 形式的“POST”WEB 数据?我搜索了-
方法(“发布”)
在帮助文件中,却没有发现类似的代码。