GithubHelp home page GithubHelp logo

新增代理网站之注册 about proxypool HOT 4 CLOSED

henson avatar henson commented on July 19, 2024
新增代理网站之注册

from proxypool.

Comments (4)

xgfone avatar xgfone commented on July 19, 2024

可以参考一下标准库 database/sql 的实现:在 database/sql/driver 下定义了驱动的要实现的 interface,然后在 database/sql 中有一个 Register 函数来把某个具体的驱动注册到 database/sql 下,这样,使用者就不用关心驱动是如何实现的,只需要知道有什么驱动即可。而且,由于有 Register 函数,所以,在实现驱动时,可以在包的初始化函数 init 中自动进行注册,使用者只需要导入即可,其它的什么都不用做。

标准库 database/sql 是个很好借鉴的例子。

from proxypool.

henson avatar henson commented on July 19, 2024

@xgfone 提了建议之后,我认真想了想,其实目前的代码对于注册一个新的代理采集接口,其实改动很小,只需要在getter包下新增一个采集函数,甚至可以不需要新建一个文件(新建文件是为了方便归档采集函数),

// 5u.go
// Data5u get ip from data5u.com
func Data5u() (result []*models.IP) {
	//处理逻辑
	...
	log.Println("Data5u done.")
	return
}

然后在main.go的run函数中添加或删除该采集函数

funs := []func() []*models.IP{
		getter.Data5u,
		getter.IP66,
		getter.KDL,
		getter.GBJ,
		getter.Xici,
		getter.XDL,
		//getter.IP181,
		//getter.YDL,
		getter.PLP,
	}

对主体程序改动其实并不大。

from proxypool.

henson avatar henson commented on July 19, 2024

可能目前急需要解决的是,建立一个采集出错的处理机制,自动摒弃掉出错的采集函数,而不影响全局。因为几次碰到有小伙伴说编译程序出错,检测代码后发现都是被采集网站改了或者是无法访问了,造成了代码出错。

from proxypool.

henson avatar henson commented on July 19, 2024

已实现简单的容错机制,即便爬虫出错了也不会影响到主体程序的运行。出错的采集进程会被主线程忽略,其它正常的采集进程仍将继续工作。

from proxypool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.