如何在Golang中使用CSS选择器
在Ruby中,我有类似contents = html_doc.css(“ img + a”)
的东西。我该怎么做?
我正在尝试使用Goquery,但我不确定如何转换它。具体来说,我尝试了doc.find(“ img”),但由于某种原因找不到任何东西
:这是我试图解析的http:
<img src="/icons/folder.gif" alt="[DIR]"> <a href="convobot-main/">convobot-main/</a> 2022-01-27 13:55 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="matlab/">matlab/</a> 2022-01-31 11:58 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test/">test/</a> 2022-01-27 13:52 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test3%20-%20Copy/">test3 - Copy/</a> 2022-02-09 15:09 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test3/">test3/</a> 2022-02-09 10:47 -
<img src="/icons/unknown.gif" alt="[ ]"> <a href="Quadractic.mlx">Quadractic.mlx</a> 2022-01-21 15:02 3.3K
</pre>
我正在寻求获取诸如quadractic.mlx之类的文件名
In Ruby, I have something like contents = html_doc.css("img + a")
. How would I do this in Go?
I am trying to use Goquery but I am unsure of how to convert it. Specifically, I tried doc.find("img") but it doesn't find anything for some reason
Edit: Here is the HTTP I'm trying to parse through:
<img src="/icons/folder.gif" alt="[DIR]"> <a href="convobot-main/">convobot-main/</a> 2022-01-27 13:55 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="matlab/">matlab/</a> 2022-01-31 11:58 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test/">test/</a> 2022-01-27 13:52 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test3%20-%20Copy/">test3 - Copy/</a> 2022-02-09 15:09 -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test3/">test3/</a> 2022-02-09 10:47 -
<img src="/icons/unknown.gif" alt="[ ]"> <a href="Quadractic.mlx">Quadractic.mlx</a> 2022-01-21 15:02 3.3K
</pre>
I am looking to get the file names like Quadractic.mlx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论