Greasemonkey- 从搜索引擎结果页面中随机挑选单词
我正在做一个小项目,但我似乎陷入了困境。希望你们中的一些伟大的人能够在这方面帮助我。
我试图找到一种简单而有效的方法来从搜索引擎结果页面中挑选出一个或多个随机单词。这是我坚持的部分。
挑选出来后,我会将单词存储在变量中。
搜索结果如下所示: http://i54.tinypic.com/34fllw1.png
谢谢提前。任何提示/帮助将不胜感激!
编辑:有没有办法我能够挑选出一串随机长度的连续单词?
I am working on a little project but I seem to be stuck at this point. Hopefully, some of you great people will be able to help me out on this.
I am trying to figure out a simple and efficient way of pick out a RANDOM word or words from a page of search engine results. This is the part I am stuck on.
After picking it out, I would store the word(s) in a variable.
The search results look like this: http://i54.tinypic.com/34fllw1.png
Thanks in advance. Any tips/help would be greatly appreciated!
EDIT: Is there a way I would be able to pick out a string of consecutive words of random length?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Google 用于描述的类是
st
,因此这里是 Dr.Molle 解决方案的改进:并挑选几个词:
Ad@m
The class Google uses for descriptions is
st
, so here's an improvement of Dr.Molle's solutiom:And to pick a few words out:
Ad@m
这是一个完整的 Greasemonkey 脚本,它仅从描述中获取任意数量的随机单词,并更好地处理各种 Google 搜索页面(它们会稍微更改 DOM,具体取决于页面的获取方式。)
Here's a complete Greasemonkey script that grabs an arbitrary number of random words, just from the descriptions, and handles the variety of Google search pages a little better (They change the DOM slightly, depending on how the page was obtained.)
下面是一个适用于 google.com 的示例。
搜索结果列在 ID 为“rso”的元素中。
正则表达式匹配至少包含 3 个字符 az 的字符串
Here is an example that works with google.com
The searchresults are listed in an element with the ID "rso".
The regexp matches strings consisting of at least 3 chars a-z