如何使用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 數據?我搜索了-
方法(“發布”)
在幫助文件中,卻沒有發現類似的代碼。