Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Java программирование > Общие вопросы по Java, Java SE, Kotlin
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 20.02.2018, 01:14   #1
Antonio12345
Новичок
Джуниор
 
Регистрация: 13.02.2018
Сообщений: 1
По умолчанию парсинг.JS лоф файла в .XML

господа просвященные,
помогите пожалуйста парсануть log1.JS лог фаил в эдентичный log2.XML

пример:
Log1.JS

var mime_samples = [
{ 'mime': 'application/javascript', 'samples': [
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-00/BenchmarkTest00013', 'dir': '_m0/0', 'linked': 5, 'len': 7 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-00/BenchmarkTest00041?password=skipfis h&BenchmarkTest00041=\x27skip\x27\x 27\x27\x22fish\x22\x22\x22', 'dir': '_m0/1', 'linked': 5, 'len': 16 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-00/BenchmarkTest00047', 'dir': '_m0/2', 'linked': 5, 'len': 88 } ]
},
{ 'mime': 'application/xhtml+xml', 'samples': [
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-05/BenchmarkTest02694.html', 'dir': '_m1/0', 'linked': 2, 'len': 1100 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-05/BenchmarkTest02691.html', 'dir': '_m1/1', 'linked': 2, 'len': 887 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-01/BenchmarkTest01047.html', 'dir': '_m1/2', 'linked': 2, 'len': 2497 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-01/BenchmarkTest00556.html', 'dir': '_m1/3', 'linked': 2, 'len': 2676 },
{ 'url': 'https://192.168.10.150:8443/benchmark/', 'dir': '_m1/4', 'linked': 5, 'len': 1742 },
{ 'url': 'https://192.168.10.150:8443/benchmark/cmdi-00/BenchmarkTest00407.html', 'dir': '_m1/5', 'linked': 2, 'len': 1012 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-01/BenchmarkTest00711', 'dir': '_m1/6', 'linked': 5, 'len': 77 },
{ 'url': 'https://192.168.10.150:8443/benchmark/404.html', 'dir': '_m1/7', 'linked': 0, 'len': 672 },
{ 'url': 'https://192.168.10.150:8443/benchmark/cmdi-Index.html', 'dir': '_m1/8', 'linked': 2, 'len': 27169 },
{ 'url': 'https://192.168.10.150:8443/benchmark/ldapi-Index.html', 'dir': '_m1/9', 'linked': 2, 'len': 7249 },
{ 'url': 'https://192.168.10.150:8443/benchmark/securecookie-Index.html', 'dir': '_m1/10', 'linked': 2, 'len': 8597 },
{ 'url': 'https://192.168.10.150:8443/benchmark/sqli-Index.html', 'dir': '_m1/11', 'linked': 2, 'len': 53783 },
{ 'url': 'https://192.168.10.150:8443/benchmark/trustbound-Index.html', 'dir': '_m1/12', 'linked': 2, 'len': 15032 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xpathi-Index.html', 'dir': '_m1/13', 'linked': 2, 'len': 4897 },
{ 'url': 'https://192.168.10.150:8443/benchmark/xss-Index.html', 'dir': '_m1/14', 'linked': 2, 'len': 46999 } ]
},

log2.xml:
<?xml version="1.0"?><tool1_report="1.0.0 " generated="Sun, 24 Dec 2017 03:30:36">
<site name="https://192.168.10.150:8443" host="192.168.10.150" port="8443" ssl="true"><alerts><alertitem>
<pluginid>10016</pluginid>
<alert>Web Browser XSS Protection Not Enabled</alert>
<name>Web Browser XSS Protection Not Enabled</name>
<riskcode>1</riskcode>
<confidence>2</confidence>
<riskdesc>Low (Medium)</riskdesc>
<desc>&lt;p&gt;Web Browser XSS Protection is not enabled, or is disabled by the configuration of the &apos;X-XSS-Protection&apos; HTTP response header on the web server&lt;/p&gt;</desc>
<instances>
<instance>
<uri>https://192.168.10.150:8443/benchmark/sqli-03/BenchmarkTest01476</uri>
<method>POST</method>
<param>X-XSS-Protection</param>
</instance>
<instance>
<uri>https://192.168.10.150:8443/benchmark/cmdi-00/BenchmarkTest00658.html?BenchmarkTe st00658=SafeText</uri>
<method>GET</method>
<param>X-XSS-Protection</param>
</instance>
<instance>
<uri>https://192.168.10.150:8443/benchmark/trustbound-01/BenchmarkTest01619.html?BenchmarkTe st01619=SafeText</uri>
<method>GET</method>
<param>X-XSS-Protection</param>
</instance>
<instance>
<uri>https://192.168.10.150:8443/benchmark/cmdi-02/BenchmarkTest02058.html?BenchmarkTe st02058=SafeText</uri>
<method>GET</method>

подкиньте плиз хинт, в том ли иду направлении?

package maven;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

public class HtmlParse1 {



public static void main(String[] args) {

Document doc;
try {


/////////File input = new File("src/main/index.html");
File input = new File("src/main/test1.txt");
//parsisng document with Jsoup.parse method
doc = Jsoup.parse(input,"UTF-8");
// get page title
String title = doc.title();
System.out.println("title : " + title);

// get all links

///Elements links = doc.select("a[href]");
Elements links = doc.select("url[https]");
/// Elements links = doc.select("a[src=https://192.168.10.150:8443/benchmark/cmdi-00/BenchmarkTest00480]");

for (Element link : links) {

// get the value from href attribute
///System.out.println("\nlink : " + link.attr("https://192.168.10.150:8443/benchmark/cmdi-00/BenchmarkTest00480"));
////System.out.println("\nlink : " + link.attr("href"));
System.out.println("\nlink : " + link.attr("url"));
System.out.println("text : " + link.text());

}

} catch (IOException e) {
e.printStackTrace();
}

}

}

заранее спасибо,
Antonio12345 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Парсинг xml Dewi1 PHP 9 19.05.2014 21:26
парсинг XMl файла, кодировка spirit-ua PHP 18 19.02.2014 08:24
C#. Парсинг XML-файла с использованием библиотеки System.xml.linq Gift020 Помощь студентам 5 04.04.2013 13:44
парсинг xml файла 3Gern Общие вопросы по Java, Java SE, Kotlin 0 14.11.2012 07:04
Парсинг XML. Abuhamed PHP 1 01.06.2011 22:24