gpt4 book ai didi

javascript - 无法通过 jsoup 从 html 中提取我想要的元素

转载 作者:行者123 更新时间:2023-11-28 06:41:06 25 4
gpt4 key购买 nike

页面在这里 http://www.yildiz.edu.tr/etkinlikler/

来源:查看源代码:http://www.yildiz.edu.tr/etkinlikler/

我不想放截图,因为它真的很长。我必须放很多屏幕截图。

我想要这个

title: 'ss Event',
start: new Date(y, m, 1)

不是全部,仅在标题和日期之后。

但似乎没有类或其他 header ,因为它在 javascript 类中:

 </div>
</div>
</div>


</div> </div>
</div> <script>
$(document).ready(function() {

var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();

$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: false,
events: [
{
title: 'birthday party',
start: new Date(2015, 9, 26),
end: new Date(2015, 10, 13),
url: 'http://www.yildiz.edu.tr/etkinlikler/Uygarlıkların Geçiş Yolu & Anadolu Peyzajı/237'

},


{
title: 'Concert',
start: new Date(2015, 5, 12),
end: new Date(2015, 5, 19),
url: 'http://www.yildiz.edu.tr/etkinlikler/İki Seçki İki Salon İki Sergi/233'

},

]
});

});

</script>

<style type='text/css'>
#calendar {
width: 900px;
margin: 0 auto;
}

</style>

我试过了

Elements event = document.select("#events");

但它不起作用。我应该使用其他工具吗?

最佳答案

Document doc = Jsoup.connect("http://www.yildiz.edu.tr/etkinlikler/").get();
String script = doc.select("script").get(10).toString();
String pattern = "\\{\\s*title\\s*:\\s*(.*),\\s*start\\s*:\\s*(.*),\\s*end.*";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(script);
while (m.find()) {
System.out.println(m.group(1) + " -> " + m.group(2));
}

输出:

'Long Event' -> new Date(y, m, d-5)
'Lunch' -> new Date(y, m, d, 12, 0)
'Birthday Party' -> new Date(y, m, d+1, 19, 0)
'Kemal Gök Fotoğraf Sergisi :Kentleşme Sürecinde Çocuk İşçiler' -> new Date(2015, 10, 17)
'Uygarlıkların Geçiş Yolu & Anadolu Peyzajı' -> new Date(2015, 9, 26)
'Vizöre Çarpanlar' -> new Date(2015, 8, 9)
'İki Seçki İki Salon İki Sergi' -> new Date(2015, 5, 12)

关于javascript - 无法通过 jsoup 从 html 中提取我想要的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33808193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com