5 examples of 'beautiful soup find by class' in Python

Every line of 'beautiful soup find by class' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
18def finder(driver):
19 element = driver.find_element_by_class_name(element_class)
20 assert element.size['width'] == width
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

702def __get_class__(self, class_name, as_list=True, timeout=Global.large_min):
703 wait = WebDriverWait(self.driver, timeout)
704 wait.until(ec.presence_of_element_located((By.CLASS_NAME, class_name)))
705 if as_list:
706 return self.driver.find_elements_by_class_name(class_name)
707 else:
708 return self.driver.find_element_by_class_name(class_name)
11def get_soup(url,header):
12 return BeautifulSoup(urllib2.urlopen(urllib2.Request(url,headers=header)),'lxml')
99def find_element_by_class_name(self, class_name):
100 """
101 Find an element in the DOM by class name.
102
103 Args:
104 class_name:
105
106 Returns:
107 WebElement
108 """
109 ele = self.soup.find(attrs={'class': class_name})
110 if ele is None:
111 raise NoSuchElementException('The element could not be located by class name: {}'.format(class_name))
112
113 return WebElement(ele, self.current_response, self.current_url, parent=self.id)
146def FindClasses(self, classname, obj=None):
147 """Find all web elements with classname.
148
149 Args:
150 classname: string, class to search for.
151 obj: web element object to search within.
152 Returns:
153 list of web element objects containing classname.
154 """
155 try:
156 self.GetWait().until(EC.presence_of_all_elements_located((By.CLASS_NAME,
157 classname)))
158 except TimeoutException:
159 self.logger.error('Timed out looking for class: %s', classname)
160 return None
161 else:
162 try:
163 if obj:
164 elements = obj.find_elements_by_class_name(classname)
165 else:
166 elements = self.driver.find_elements_by_class_name(classname)
167 except NoSuchElementException:
168 self.logger.error('Error finding %s class name.', classname)
169 return None
170 return elements

Related snippets