Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Hi guys

I need to create a simple java program that allows me to get a m3u8 link contained in the website passed as a parameter.
I have to retrieve the http header of the website ?, how can I do?


google dev tools (f12)
https://i.imgur.com/4xgchaw.png[^]

What I have tried:

i tried to use the getHeaderFields() method but it didn't work
Posted
Updated 3-Aug-19 4:34am
v3
Comments
Richard MacCutchan 3-Aug-19 9:39am    
For future reference, stating, "it didn't work", provides no useful information. If you want help with your problems then please provide full details: relevant code, error messages, what you expect against what actually happens, etc.

1 solution

Since you want to parse an HTML document and read its contents, there are two ways. First of them (the easy way) would be to use an HTML parser and then read the header values one by one. I have not heard of any in Java but with C# we had HtmlAgilityPack[^]; which in Java is somewhere to be like JTidy[^].

Second way is by using the Java APIs, which as per your statement you say,
Quote:
i tried to use the getHeaderFields() method but it didn't work
Luckily, for us, here is a thread on SO where the OP said the same thing that getHeaderFields() does not work for them, so they were provided with a solution for that, please see that thread. It takes more than just an extra code line or a rewrite, that is why I am attaching the link to the thread for you to read and go through, java - Getting raw HTTP response headers - Stack Overflow[^]
 
Share this answer
 
v2
Comments
[no name] 3-Aug-19 10:42am    
Thanks for the reply, but unfortunately the proposed solutions have not solved the problem.
I have attached an image of the chrome inspect tool (section network tab header)
what I want to get in java or in another way (javascript for example) is the "Request Url" field (Sometimes the link in the "Request Url" corresponds to the web page I'm visiting but in my case it represents the m3u8 link that i need.)
Demon.D. Dragon 29-Jan-22 3:51am    
Bro are you able to fetch that m3u8 url.?
If so then tellme the java Code for it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900