• 大小: 3KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: Java
  • 标签: Java  

资源简介

根据网站上的url进行请求http后返回,解析处理代码,学习参考

资源截图

代码片段和文件信息

package com.hackstrive.translate.caifutongstock;

import com.hackstrive.getstock.market.ToolsStockMarket;
import com.hackstrive.getstock.market.entity.JjzcStockView;
import com.hackstrive.getstock.market.entity.MoreDate;

import net.sf.json.JSONArray;
import net.sf.json.JSONobject;

public class OrganizationPositionsData {

public String  getOrganizationPositionsUrl(String httpUrl){
ToolsStockMarket  tsm=new ToolsStockMarket();
String jsonResult = tsm.requestCaiFuTong(httpUrl);
String startStrStope=jsonResult.substring(jsonResult.lastIndexOf(“[“)+1 jsonResult.lastIndexOf(“]“));
return startStrStope;
}
public String  getOrganizationPositionsSinaDateUrl(String httpUrl){
ToolsStockMarket  tsm=new ToolsStockMarket();
String jsonResult = tsm.requestSinaDate(httpUrl);
String startStrStope=jsonResult.substring(jsonResult.lastIndexOf(“[{“) jsonResult.lastIndexOf(“}]“)+2);
return startStrStope;
}

public String  getOrganizationPositionsUrl163(String httpUrl){
ToolsStockMarket  tsm=new ToolsStockMarket();
String jsonResult = tsm.request163Data(httpUrl);
String startStrStope=jsonResult;
return startStrStope;
}
public String  getOrganizationPositionsUrlTest(String httpUrl){
ToolsStockMarket  tsm=new ToolsStockMarket();
String jsonResult = tsm.requestTestData(httpUrl);
String startStrStope=jsonResult.substring(jsonResult.lastIndexOf(“(“)+1 jsonResult.lastIndexOf(“)“));
return startStrStope;
}

/**
 * @param args
 */
public static void main(String[] args) {
//个股详细历史数据String url =“http://quotes.money.163.com/service/chddata.html?code=1300056&start=20170227&end=20170327&fields=TCLOSE;HIGH;LOW;TOPEN;LCLOSE;CHG;PCHG;TURNOVER;VOTURNOVER;VATURNOVER;TCAP;MCAP“;
//String url =“http://www.szse.cn/szseWeb/ShowReport.szse?SHOWTYPE=xlsx&CATALOGID=1110&tab1PAGENUM=1&ENCODE=1&TABKEY=tab1“;
  OrganizationPositionsData cst=new OrganizationPositionsData();
    String url=“http://quotes.money.163.com/hs/marketdata/service/nbjy.php?host=/hs/marketdata/service/nbjy.php&page=0&query=symbol:300056&fields=NOSYMBOLSNAMECNAMEMHOLDER5MHOLDER6MHOLDER7BIANDONGJINEMHOLDER2MHOLDER4RELATIONDJZWREPORTDATE&sort=REPORTDATE&order=desc&count=100&type=query&initData=[object%20object]&callback=callback_511214691&req=2233“;
      String jsonString=cst.getOrganizationPositionsUrlTest(url);
      
      System.out.println(jsonString);
      
     // String str =“{\“NO\“:\“1\“\“BIANDONGJINE\“:\“10064109\“\“EXCHANGE\“:\“CNSESZ\“\“SYMBOL\“:\“300056\“\“PERSONALCODE\“:\“30056991\“\“SNAME\“:\“\\u4e09\\u7ef4\\u4e1d\“\“COMPANYCODE\“:\“80139912\“\“REPORTDATE\“:\“2017-03-02\“\“CNAME\“:\“\\u4e18\\u56fd\\u5f3a\“\“CNAME2\“:\“\\u4e18\\u56fd\\u5f3a\“\“DJGGX\“:\“0\“\“MHOLDER6\“:\“561300\“\“MHOLDER2\“:\“37084920\“\“MHOLDER7\“:\“17.93\“\“MHOLDER4\“:\“\\u7ade\\u4ef7\\u4ea4\\u6613\“\“MHOLDER3\“:\“01\“\“MHOLDER5\“:\“\\u8d2d\\u4e70\“\“DJZW\“:\“\\u9500\\u552e\\u603b\\u76d1\“\“CODE

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-11-02 23:47  java解析页面http\
     文件        3554  2017-03-28 23:41  java解析页面http\OrganizationPositionsData.java
     文件        6084  2017-03-28 22:44  java解析页面http\ToolsStockMarket.java

评论

共有 条评论