0

I have a link of an OPENTEXT REST API : [https://developer.opentext.com/webaccess/#url=%2Fawd%2Fresources%2Fapis%2Fcs-rest-api-for-cs-16-s&tab=501] and I want to get the json file of this rest api so I used this link [https://developer.opentext.com/webaccess/#url=%2Fawd%2Fresources%2Fapis%2Fcs-rest-api-for-cs-16-s&tab=501/api-docs.json] and I tried to parse it using jsoup (since this is a web page) but it does not show me the requiered content because it's using an and it's not shown in the main HTML code! After many tries I figured out that the main URL for this json file is : [https://developer.opentext.com/awd/resources/apis/cs-rest-api-for-cs-16-s/api-docs.json] which is invoked to this web page using XHR (I figured it out using Google dev tools). Now my question is how to get the main URL of this json file using the first URL. and please do not give me this link [How to get XMLHTTPRequest response text of external web page using Java? because it responses not my needs

maryem neyli
  • 467
  • 3
  • 20
  • XMLHTTPRequest is JavaScript. The language that is actually named ECMAScript. Java is a completely unrelated language. So I think that's part one of your troubles. You need to show us you current code. And make sure you have the correct language for what you want to do. The apache-http* components are Java. So the evidence is leaning one way, but the you throw xmlhttprequest in there (and that is ECMAScript).... – Elliott Frisch Apr 19 '20 at 17:22
  • @ElliottFrisch look I edited the question. is there is any way to gest that api-docs.json file ? – maryem neyli Apr 19 '20 at 17:26
  • This is a **VERY** common thing (I think)... They actually have a lot of answers. Try this: [Creating REST/JSON APIs](https://stackoverflow.com/questions/19155123/creating-rest-json-apis) And pay attention to the standard-java classes that are used, since they've been doing this for a long time... Here's another [How to consume REST in Java - duplicate](https://stackoverflow.com/questions/12916169/how-to-consume-rest-in-java)... Notice the "Big Three" `BufferedReader`, `URL`, and `HttpURLConnection` –  Apr 19 '20 at 18:10
  • **NEXT** You will, possibly, need the JSON library. (**OR**) you will have to use Regular-Expressions... Search for JSON which can parse the text-content that you will be receiving from the REST Server. –  Apr 19 '20 at 18:13
  • And if **that** doesn't work, here is a list of [Headless Browsers](https://github.com/dhamaniasad/HeadlessBrowsers). And I realize that might sound rude or aggressive. But I didn't name it that. And it's possible that's what you're looking for (if you want to use xmlhttprequest it kind of has to be). I have been doing this a long time. There are a lot of web browsers and web sites in the world. I do not claim to know them all. But I do know how the web actually works. And I'm sorry to say it's like hamburger or sausage, *most* people would probably prefer to **not** know. – Elliott Frisch Apr 19 '20 at 18:16

1 Answers1

0

You can copy this request as Curl and then -> use Curl in Java. This is I think the simplest way but not the best one.

  • URL includes a lot of personalized session identifiers. And the site has a ReST API. And this entire web scraping exercise is fraught with a single change on the third-party site breaking everything. A third-party site with a ReST API.... – Elliott Frisch Apr 19 '20 at 17:36
  • @ElliottFrisch So I think it's impossible to get that file using java? – maryem neyli Apr 19 '20 at 17:38
  • It's possible. Show us your code. Tell us the base url. With what you have so far shown, I would have to write everything from scratch to provide you a solution. After spending a bit of time figuring out what you're trying to do. Which you still haven't said. – Elliott Frisch Apr 19 '20 at 17:40