简体   繁体   English

jsoup - 无法获取特定网站

[英]jsoup - Not able to fetch a specific website

I'm using latest jsoup (1.13.1) in latest Eclipse IDE for Java Developers (includes Incubating components) Version: 2020-09 (4.17.0) Build id: 20200910-1200.我在 Java 开发人员的最新 Eclipse IDE(包括孵化组件)中使用最新的 jsoup (1.13.1) 版本:2020-09 (4.17.0) 构建 ID:20200910-1200。

I'm trying to parse a very specific website, but with no success.我正在尝试解析一个非常具体的网站,但没有成功。 After I execute these lines: doc = Jsoup.connect("http://pokehb.pw/%D7%A2%D7%95%D7%A0%D7%94/21/%D7%A4%D7%A8%D7%A7/43").get();在我执行这些行后: doc = Jsoup.connect("http://pokehb.pw/%D7%A2%D7%95%D7%A0%D7%94/21/%D7%A4%D7%A8%D7 %A7/43").get(); doc.select("title").forEach(System.out::println); doc.select("title").forEach(System.out::println);

Nothing gets printed.什么都不会打印。 It's not just the , any element or property of the page is not available.不仅仅是 ,页面的任何元素或属性都不可用。

Yes, the URL is weird, but this is the one I need, I can browse it fine in Chrome.是的,URL 很奇怪,但这是我需要的,我可以在 Chrome 中正常浏览。 I also know this is now due to the Hebrew in the website, since other Hebrew sites works ok.我也知道这是由于网站上的希伯来语,因为其他希伯来语网站工作正常。

For example, using this URL seems fine: https://context.reverso.net/translation/hebrew-english/%D7%9C%D7%9B%D7%AA%D7%95%D7%91%D7%AA+url例如,使用这个 URL 似乎没问题: https : //context.reverso.net/translation/hebrew-english/%D7%9C%D7%9B%D7%AA%D7%95%D7%91%D7%AA+网址

Any hint on what can be done?关于可以做什么的任何提示?

What I can tell you is there's a "laravel_session" in the cookies.我可以告诉你的是 cookie 中有一个“laravel_session”。 This suggests you'll need a more capable technology than JSoup.这表明您需要比 JSoup 更强大的技术。 Try HtmlUnit instead and it might work.试试 HtmlUnit,它可能会工作。

What I ended up doing is using this command: doc = Jsoup.parse(driver.getPageSource());我最终做的是使用这个命令: doc = Jsoup.parse(driver.getPageSource());

Which brought all of the page's source into the doc.这将所有页面的源代码都带入了文档中。 From there it was a simple use of getElementsByClass and getElementsByTag.从那里可以简单地使用 getElementsByClass 和 getElementsByTag。

Hope this helps someone, and thanks Rob for trying to answer.希望这对某人有所帮助,并感谢 Rob 尝试回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM