使用jsoup来解析“动态"消息.页 [英] Using jsoup to parse a "dynamic" page

查看:171
本文介绍了使用jsoup来解析“动态"消息.页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个学校项目工作,而我在解析网页时遇到了麻烦.之所以称其为动态",是因为每次我们更改搜索参数时,内容都会改变.

I'm working on a project for school and Im having trouble parsing a webpage. I call it "dynamic" because the content changes every time we change a search parameter.

这是链接 https://en.mygon.com/#!guia/todas-as-categorias/portugal/amanha/qualquer-hora

单击它会显示一些搜索结果.但是,我无法在页面源代码中找到它们,但我确实确定搜索与脚本有关(我认为).

When you click it, it will show some search results. However I can't find them in the page source code, but I do identify that the search is related to a script (i think).

     <input id="search-words-button" type="button" class="action submit" onClick="searchWordsElement();" value="GO"/>

如何使用jsoup解析此页面的结果?

How can i use jsoup to parse the results from this page?

谢谢

推荐答案

您无法在源页面上找到它,因为该链接正在运行基于该链接返回JSON的javascript动态填充页面的

You cant find it on the source page because the link is running a javascript that is populating the page dynamically based on a return JSON from this link

https://en.mygon.com/MGMDW/REST/web/client/shops/getShops?startIndex=0&pageSize=30&hourInterval=0&onlyPromotions=false&categoryId=0&day=5&searchWords=sushi&languageCode=en_EN&originMygon=true&capital=portugal%2C+portugal&_=1410373067855

在这种情况下,JSoup不会为您提供帮助.

JSoup wont help you in this case.

运行我发布的链接,并将searchWords = sushi更改为所需的搜索,结果将是易于解析的JSON

Run the link that I posted and change searchWords=sushi for the search that you want and the result will be a JSON that is easily parsed

[] s

这篇关于使用jsoup来解析“动态"消息.页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆