如果您在Web檢查器中檢查網絡選項卡,則會找到用於加載數據的URL。只需直接打電話,然後按照你的意願去做。這是一個jQuery示例(因爲我可以使用片段工具演示該概念),但使用WebClient.DownloadString()
方法從C#調用它很簡單。
var url = 'https://core-api.barchart.com/v1/quotes/get?fields=symbol%2CcontractName%2ClastPrice%2CpriceChange%2CopenPrice%2ChighPrice%2ClowPrice%2CpreviousPrice%2Cvolume%2CopenInterest%2CtradeTime%2CsymbolCode%2CsymbolType%2ChasOptions&list=futures.contractInRoot&root=HG&meta=field.shortName%2Cfield.description&hasOptions=true&raw=1';
$('#data').load(url);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Data: <br />
<textarea id="data" cols="50" rows="8"></textarea>
C#例如:
public static void DownloadString (string address)
{
WebClient client = new WebClient();
string reply = client.DownloadString (address);
Console.WriteLine (reply);
return reply;
}
var url = 'https://core-api.barchart.com/v1/quotes/get?fields=symbol%2CcontractName%2ClastPrice%2CpriceChange%2CopenPrice%2ChighPrice%2ClowPrice%2CpreviousPrice%2Cvolume%2CopenInterest%2CtradeTime%2CsymbolCode%2CsymbolType%2ChasOptions&list=futures.contractInRoot&root=HG&meta=field.shortName%2Cfield.description&hasOptions=true&raw=1';
var data = DownloadString(url);