Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何让AirSpider在调用时每次的浏览器实例都为最新 #254

Open
javaswing opened this issue Apr 24, 2024 · 1 comment
Open

Comments

@javaswing
Copy link

各位大佬好,最近在使用feapder这个爬虫框架,框架设计的非常棒。自己由于不是专业的爬虫,在使用过程中有一些问题,自己完成没有思路了。希望得到大佬位的指点!不胜感激

有如下的需求:

现在使用了AirSpider浏览器渲染(Playwright)模式,进行抓取两个网站的数据,针对不同的API进行拦截json。
在一个启动的服务,通过接口交互,来触发并以xxxSpider().start()方式调用。

问题

在执行其中其中一个AirSpider时,通过url_regexes拦截的数据,都是正常且任务执行完成都通过response.close_browser(request)方式关闭了浏览器。
但是再次通过xxxSpider().start()调用第二个网站爬虫时,拦截的接口数据都为None。

自己尝试定位了问题,发现执行第二网站爬虫时,使用的浏览器实例为第一个爬虫完成后,框架中缓存的(可以理解为第二个爬虫的设置都没有生效)浏览器实例,目前没有找到解决方案,恳请各位大佬指点下!

期望

希望每次执行xxxSpider().start()之后系统都能按设定重新生成一个指定的浏览器实例,不使用框架缓存的实例

复现代码仓库

https://github.com/javaswing/feapder-demo

@javaswing javaswing changed the title 如何让AirSpider支持方法级别的调整 如何让AirSpider在调用时每次的浏览器实例都为最新 Apr 24, 2024
@Boris-code
Copy link
Owner

浏览器池是单例的,你这个情况 需要两个起不同的进程运行,或者将所有拦截写到 _url_regexes 里。你可以在setting里配置,这样无需每个爬虫都写一遍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants