8000 Crawl Meta Data from Dictionary by SorrowHarvest · Pull Request #1 · gerr135/wann · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Crawl Meta Data from Dictionary #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Crawl Meta Data from Dictionary #1

wants to merge 10 commits into from

Conversation

SorrowHarvest
Copy link

Execute Java Script to crawl metadata and extract to text
https://rosettacode.org/wiki/Execute_a_system_command#Ada

`package manager;

import java.io.IOException;
import java.io.FileWriter;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class charter_host {

public charter_host() {
	HttpClient client = HttpClient.newHttpClient();
    HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://www.cryptocurrencychart.com/live-prices/XMR"))
            .GET() // GET is default
            .build();

    HttpResponse<String> response = null;
	try {
		response = client.send(request,
		        HttpResponse.BodyHandlers.ofString());
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	try {
        FileWriter imprint_chart = new FileWriter("coinchart.txt", false);
        imprint_chart.write(response.body());
        imprint_chart.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
	
    System.out.println(response.body());
}

}
`

`package manager;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class main_frame {
private static String chart_file = "C:\Users\Hector\eclipse\__broker\src\manager\coinchart.txt";
private static int f_width = 800;
private static int f_height = 600;

public static JFrame __frame(String coin_type) {
	String title = "Broker : " + coin_type;
	JFrame f = new JFrame(title);
	
	f.setSize(f_width, f_height);
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	return f;
}

public static void check_if_red(String coin_type) {
	
	/*-------------:| HTML HANDLE METADATA |:--------------------------
	 * Objective : GET hyper text content than imprint into a file
	 * 	Read the contents of the text with in the imprint
	 * 	Compare value with in brackets or dividers
	 *  Compare value to extract data to state and watch
	 *   Market shares and currency escalation.
	 *  Trade value if is profitable.
	 * ----------------------------------------------------------------
	 * ---------:| www.cryptocurrencychart.com |:----------------------
	 * https://www.cryptocurrencychart.com/live-prices/XMR
	 * 
	 * <span class="change" data-change="0.040212107598112334" 
	 * title="Price change %">+4.02%</span>
	 *  
	 * <span class="price currency" data-value="191.96812211208" 
	 * title="Current coin price">$191.96</span>
	 * 
	 * <div data-id="370" class="coin coin-block block-green">
			<a href="#remove" class="close"></a>
			<span class="title">Monero <span class="symbol">(XMR)</span>
			</span>
			<span class="price currency" data-value="191.96812211208" title="Current coin price">$191.96</span>
			<span class="change" data-change="0.040212107598112" title="Price change %">+4.02%</span>
			<br class="break-1">
			<span class="my-value-container">
				<input class="my-coin-input data-price" type="text" id="my-coin-XMR" data-value="0" data-price="191.96812211208" value="0">
				<span class="my-value" title="The value of the coins in the selected fiat currency">$0.00</span>
				<span class="my-change" title="The change in value of the coins in the selected fiat currency">$0.00</span>
			</span><br class="break-2">
			<span class="ratio-description">% of total</span>
			<span class="ratio">0.00%</span>
		</div>
		
	 * -----------------------------------------------------------------
	 * ---------:| www.coinmarketcap.com |:-----------------------------
	 * https://coinmarketcap.com/currencies/monero/
	 *
	 *  <div class="priceValue "><span>$189.84</span></div>
	 *  
	 *  <span style="font-size:14px;font-weight:600;padding:5px 10px" class="sc-15yy2pl-0 feeyND">
	 *  <span class="icon-Caret-down"> </span>1.25<!-- -->%</span>
	 *  <span class="icon-Caret-down"></span>
	 *  
	 */
	
	Path chart_map = Path.of(chart_file);
	try {
		String chart_string = Files.readString(chart_map);
		System.out.println(chart_string);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}	
	String span_coin_type = "<span class=\"symbol\">("+ coin_type + ")</span>";
    
	
    Pattern pattern = Pattern.compile("<span class=\\\"symbol\\\">(\\S+)</span>");
    Matcher matcher = pattern.matcher(span_coin_type);
    if (matcher.find()) {
       String result = matcher.group(1);
       System.out.println(result);
    }

}


public static void main(String[] args) {
	JFrame context = __frame("ZAR");
	context.setVisible(true);
	
	check_if_red("BTC");
	//charter_host htclient = new charter_host();
}

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0