Reputation: 2059
I want to get the title of a webpage without actually displaying the website inside my app.
Only want to receive the title. (or header information)
I searched stack, but were not able to find a solution
Upvotes: 0
Views: 55
Reputation: 6357
Okay, so I won't spoon-feed you with code, but you can do it in two ways.
<title>
tag. HttpURLConnection
. a) Connect to the website using HttpURLConnection
.
b) Read the first few thousand bytes (it will most probably contain the <title>
tag).
c) Search for the Title using this regex <title>(.*)<\/title>
. Check the regex here.
If you want to know how to use regex for title extraction, check the answer linked by GeorgeGkas.
Upvotes: 1