Fuel Pulse
A Java library to get the fuel prices in India by city.
Loading...
Searching...
No Matches
GoodReturnsIn.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 GoodReturnsIn 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.goodreturns.in/%s-price-in-%s.html", type, city)).get();
14 return Float.parseFloat(doc.select(".fuel-block-details").text().split("/")[0].replace("₹", "").strip());
15 }
16}
float fetch(String city, FuelType fuelType)