Вот пример, основанный на API https://ipdata.co , который свободен до 1500 запросов / день.
Замените 8.8.8.8
на ip, который вы как искать
// Maven : Add these dependecies to your pom.xml (java6+)
//
// org.glassfish.jersey.core
// jersey-client
// 2.8
//
//
// org.glassfish.jersey.media
// jersey-media-json-jackson
// 2.8
//
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
Client client = ClientBuilder.newClient();
Response response = client.target("https://api.ipdata.co/8.8.8.8")
.request(MediaType.TEXT_PLAIN_TYPE)
.header("Accept", "application/json")
.get();
System.out.println("status: " + response.getStatus());
System.out.println("headers: " + response.getHeaders());
System.out.println("body:" + response.readEntity(String.class));
Вы можете использовать HtmlWebPackPlugin для динамического добавления скриптов к вашим HTML-страницам.
Прежде всего установите плагин:
npm install html-loader html-webpack-plugin --save-dev
Затем используйте конфигурацию:
const HtmlWebPackPlugin = require("html-webpack-plugin");
module.exports = {
entry: {
nav: './resources/js/sections/nav.js',
home: './resources/js/sections/home.js',
settings: './resources/js/sections/settings.js',
contact: './resources/js/sections/contact.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'), // folder where all tranformed files will be placed
},
rules: [
{
test: /\.html$/,
use: [{
loader: "html-loader",
options: { minimize: true }
}]
}
],
plugins: [
// create an instance of HtmlWebPackPlugin for every page of a multipage website
new HtmlWebPackPlugin({
template: "./resources/html/home.html", // take html from this path
filename: "./home.html", // name it 'home.html' and insert to the root of output folder
chunks: ['nav', 'home'] // insert dymamically nav.js and home.js to home.html
}),
new HtmlWebPackPlugin({
template: "./resources/html/settings.html",
filename: "./settings.html",
chunks: ['nav', 'settings']
}),
new HtmlWebPackPlugin({
template: "./resources/html/contact.html",
filename: "./contact.html",
chunks: ['nav', 'contact']
}),
]
}