根据搜索从网站上抓取
Scraping from a website based on a search
Objective
在Java,我想得到在https://pin1yin1.com/#我是英国人
搜索结果的文本输出
到目前为止我尝试了什么
使用 JSoup,我已经连接到页面,使用 Jsoup.connect("https://pin1yin1.com/#%E6%88%91%E6%98%AF%E8%8B%B1%E5%9B%BD%E4%BA%BA").get();
(数字和百分号自己翻译成汉字)
面临的问题
当我 运行 getAllElements()
查看它抓取的内容时,代码仅用于登录页面,即用户在 之前 看到的内容搜索,它不会获取任何搜索结果。
我查了网站,你可以直接从他们那里获取数据API,试试下面:
Document doc = Jsoup.connect("https://pin1yin1.com/pinyin/convert/?c=%E6%88%91%E6%98%AF%E8%8B%B1%E5%9B%BD%E4%BA%BA").get();
回复如下:
<html>
<head></head>
<body>
{ "q": "我是英国人", "s": "我是英国人", "t": "我是英國人", "p":
["wo3","shi4","ying1","guo2","ren2"], "e": ["I; me; my","is; are; am; yes","British person"], "c": [1,1,3] }
</body></html>
Objective
在Java,我想得到在https://pin1yin1.com/#我是英国人
到目前为止我尝试了什么
使用 JSoup,我已经连接到页面,使用 Jsoup.connect("https://pin1yin1.com/#%E6%88%91%E6%98%AF%E8%8B%B1%E5%9B%BD%E4%BA%BA").get();
(数字和百分号自己翻译成汉字)
面临的问题
当我 运行 getAllElements()
查看它抓取的内容时,代码仅用于登录页面,即用户在 之前 看到的内容搜索,它不会获取任何搜索结果。
我查了网站,你可以直接从他们那里获取数据API,试试下面:
Document doc = Jsoup.connect("https://pin1yin1.com/pinyin/convert/?c=%E6%88%91%E6%98%AF%E8%8B%B1%E5%9B%BD%E4%BA%BA").get();
回复如下:
<html>
<head></head>
<body>
{ "q": "我是英国人", "s": "我是英国人", "t": "我是英國人", "p":
["wo3","shi4","ying1","guo2","ren2"], "e": ["I; me; my","is; are; am; yes","British person"], "c": [1,1,3] }
</body></html>