Fuel Pulse
A Java library to get the fuel prices in India by city.
Loading...
Searching...
No Matches
NDTV.java
Go to the documentation of this file.
1package io.github.amithkoujalgi.fuelprices.impl;
2
3import io.github.amithkoujalgi.fuelprices.FetchHandler;
4import io.github.amithkoujalgi.fuelprices.types.FuelType;
5import org.jsoup.Jsoup;
6import org.jsoup.nodes.Document;
7
8import java.io.IOException;
9
10public class NDTV implements FetchHandler {
11 public float fetch(String city, FuelType fuelType) throws IOException {
12 String type = fuelType.name().toLowerCase();
13 Document doc = Jsoup.connect(String.format("https://www.ndtv.com/fuel-prices/%s-price-in-%s-city", type, city)).get();
14 return Float.parseFloat(doc.select(".todyPricContnr .prcContnr .font-b").text().replace("₹/L", ""));
15 }
16}
float fetch(String city, FuelType fuelType)
Definition NDTV.java:11