如何前往随机网站? -蟒蛇 [英] How do I go to a random website? - python

查看:292
本文介绍了如何前往随机网站? -蟒蛇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论语言如何,如何生成随机但有效的网站链接。实际上,它生成的网站的语言越多样化,它的性能就越好。

How to generate a random yet valid website link, regardless of languages. Actually, the more diverse the language of the website it generates, the better it is.

我一直在使用别人网页上的脚本来做到这一点, >我怎么不能依靠这些随机站点转发脚本来制作自己的脚本?。我一直在这样做:

I've been doing it by using other people's script on their webpage, how can i not rely on these random site forwarding script and make my own?. I've been doing it as such:

import webbrowser
from random import choice
random_page_generator = ['http://www.randomwebsite.com/cgi-bin/random.pl',
                         'http://www.uroulette.com/visit']
webbrowser.open(choice(random_page_generator), new=2)


推荐答案


我一直在通过使用别人网页上的脚本来做到这一点,我怎么能不依靠这些随机的网站转发脚本来制作自己的脚本呢?

I've been doing it by using other people's script on their webpage, how can i not rely on these random site forwarding script and make my own?

有两种方法可以做到这一点:

There are two ways to do this:


  • 创建自己的蜘蛛评估大量网站,并从该网站中进行选择。

  • 访问一些现有的网站网站,然后从该集合中进行选择。例如,DMOZ / ODP允许您下载其整个数据库; * Google曾经有一个自定义的随机网站URL; **等。

  • Create your own spider that amasses a huge collection of websites, and pick from that collection.
  • Access some pre-existing collection of websites, and pick from that collection. For example, DMOZ/ODP lets you download their entire database;* Google used to have a customized random site URL;** etc.

没有其他解决方法(缺少随机生成和测试的功能)有效的任意字符字符串,这是一个可笑的坏主意。)

There is no other way around it (short of randomly generating and testing valid strings of arbitrary characters, which would be a ridiculously bad idea).

为自己构建一个网络蜘蛛可能是一个有趣的项目。链接驱动的抓取库,例如 Scrapy 可以为您完成很多繁重的工作,让您编写自己关心的部分。

Building a web spider for yourself can be a fun project. Link-driven scraping libraries like Scrapy can do a lot of the grunt work for you, leaving you to write the part you care about.

*请注意,与Google或Yahoo相比,ODP是一个非常小的数据库,因为它主要是人类的。

* Note that ODP is a pretty small database compared to something like Google's or Yahoo's, because it's primarily a human-edited collection of significant websites rather than an auto-generated collection of everything anyone has put on the web.

**谷歌的随机站点功能是由受欢迎程度和您自己的驱动的搜索历史记录。但是,通过向其提供空的搜索历史记录,您可以删除方程式的该部分。无论如何,我认为它已经不存在了。

** Google's random site feature was driven by both popularity and your own search history. However, by feeding it an empty search history, you could remove that part of the equation. Anyway, I don't think it exists anymore.

这篇关于如何前往随机网站? -蟒蛇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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