mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
feat: cache screenshot ocr texts
This commit is contained in:
@@ -25,15 +25,21 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
// loop until target count achieved
|
||||
for {
|
||||
// take screenshot and get screen texts by OCR
|
||||
_, err := dExt.GetScreenTextsByOCR()
|
||||
texts, err := dExt.GetScreenTextsByOCR()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("OCR GetTexts failed")
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: check if text popup exists
|
||||
// check if text popup exists
|
||||
if isTextPopup(texts) {
|
||||
log.Info().Msg("text popup found")
|
||||
}
|
||||
|
||||
// TODO: check if live video
|
||||
// check if live video
|
||||
if isLiveVideo(texts) {
|
||||
log.Info().Msg("live video found")
|
||||
}
|
||||
|
||||
// assert feed video type
|
||||
|
||||
@@ -48,3 +54,13 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
|
||||
// return nil
|
||||
}
|
||||
|
||||
func isTextPopup(texts OCRTexts) bool {
|
||||
texts.FindTexts([]string{"确定", "取消"})
|
||||
return false
|
||||
}
|
||||
|
||||
func isLiveVideo(texts OCRTexts) bool {
|
||||
_, err := texts.FindTexts([]string{"点击进入直播间", "直播中"})
|
||||
return err == nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user