使用Selenium获取响应代码的最佳方法?

2024-09-28 03:19:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在构建一个web爬虫程序,并刚刚将Selenium添加到爬虫程序中,但我意识到,如果不在Selenium之前使用请求,就无法获取http状态代码

我使用Selenium是因为我需要在页面完全加载后获取页面内容

所以现在我的爬虫正在这样做

1. Using request to get http status_code (Counts as 1 reqeust)
1.. Got response code (200,301,400)

2. Using Selenium to get page content (Counts as 1 reqeust)
2.. Got page content from Selenium

问题是,我使用2个请求来获取完整的页面内容,是否存在这样的情况,可能没有使用Selenium,在那里我可以获取页面和响应代码,但只能使用1个请求


Tags: to代码程序http内容getasselenium

热门问题