Commit dc7b2a75 authored by Doğukan Çelik's avatar Doğukan Çelik

implementin parser v1

parent 1067ed15
......@@ -10,19 +10,19 @@ import java.net.HttpURLConnection;
import java.net.URL;
public class HttpAdapter {
public static String doRequest(String requestUrl){
public static String doRequest(String requestUrl) {
try {
URL url = new URL(requestUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while((inputLine = in.readLine()) != null){
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
return content.toString();
}catch (Exception e){
} catch (Exception e) {
throw new CollectorException("There is something wrong with http connection: " + e.getMessage());
}
}
......@@ -30,14 +30,12 @@ public class HttpAdapter {
public static void main(String[] args) throws IOException {
org.jsoup.nodes.Document doc = Jsoup.connect("https://lwn.net/Calendar/Monthly/2018-06/").get();
org.jsoup.select.Elements rows = doc.select("tr");
for(org.jsoup.nodes.Element row :rows)
{
for (org.jsoup.nodes.Element row : rows) {
Integer rowCount = 1;
Integer columnCount = 1;
Integer maxColumnCount = 8;
org.jsoup.select.Elements columns = row.select("td");
for (org.jsoup.nodes.Element column:columns)
{
for (org.jsoup.nodes.Element column : columns) {
/*if(column.className().equals("CalMDate")){
System.out.println("Date " + column.text());
......@@ -49,11 +47,11 @@ public class HttpAdapter {
System.out.println("Continue//");
System.out.println();
}*/
if(column.className().equals("CalMEvent") && !column.text().trim().equals("")){
if (column.className().equals("CalMEvent") && !column.text().trim().equals("")) {
System.out.println("Event: " + column.text() + " row:" + rowCount + " column:" + columnCount);
}
columnCount++;
if(columnCount == 8){
if (columnCount == 8) {
columnCount = 1;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment