Checks to see if a post is an image. If so, returns list with image source URL. If a NoSuchElement exception occurs, checks post for video and returns the source URLs for both the video and the video's keyframe.
(browser)
| 110 | |
| 111 | |
| 112 | def get_source_link(browser): |
| 113 | """Checks to see if a post is an image. If so, returns list with image |
| 114 | source URL. |
| 115 | If a NoSuchElement exception occurs, checks post for video and returns |
| 116 | the source URLs |
| 117 | for both the video and the video's keyframe.""" |
| 118 | source = [] |
| 119 | |
| 120 | try: |
| 121 | source.append( |
| 122 | browser.find_element( |
| 123 | By.XPATH, read_xpath(get_source_link.__name__, "image") |
| 124 | ).get_attribute("src") |
| 125 | ) |
| 126 | except NoSuchElementException: |
| 127 | source.append( |
| 128 | browser.find_element( |
| 129 | By.XPATH, read_xpath(get_source_link.__name__, "video") |
| 130 | ).get_attribute("src") |
| 131 | ) |
| 132 | source.append( |
| 133 | browser.find_element( |
| 134 | By.XPATH, read_xpath(get_source_link.__name__, "image_alt") |
| 135 | ).get_attribute("src") |
| 136 | ) |
| 137 | |
| 138 | return source |
| 139 | |
| 140 | |
| 141 | def get_clarifai_response(clarifai_api, clarifai_model, source_link, check_video): |
no test coverage detected