scrapetools.input_scraper
1from bs4 import BeautifulSoup 2from bs4.element import Tag 3 4 5def scrape_inputs(source: str) -> tuple[list[Tag]]: 6 """Searches html for various user input elements. 7 8 Returns a tuple where each element is a list of BeautifulSoup Tag elements. 9 10 The tuple elements are forms, inputs, buttons, select elements, 11 and text_areas. If an element type was not found, it will be an empty list. 12 13 The inputs, buttons, select elements, and text_areas are ones 14 not already found in a form element.""" 15 soup = BeautifulSoup(source, "html.parser") 16 forms = soup("form") 17 for form in forms: 18 form.extract() 19 inputs = soup("input") 20 buttons = soup("button") 21 selects = soup("select") 22 text_areas = soup("textAreas") 23 24 return forms, inputs, buttons, selects, text_areas
def
scrape_inputs(source: str) -> tuple[list[bs4.element.Tag]]:
6def scrape_inputs(source: str) -> tuple[list[Tag]]: 7 """Searches html for various user input elements. 8 9 Returns a tuple where each element is a list of BeautifulSoup Tag elements. 10 11 The tuple elements are forms, inputs, buttons, select elements, 12 and text_areas. If an element type was not found, it will be an empty list. 13 14 The inputs, buttons, select elements, and text_areas are ones 15 not already found in a form element.""" 16 soup = BeautifulSoup(source, "html.parser") 17 forms = soup("form") 18 for form in forms: 19 form.extract() 20 inputs = soup("input") 21 buttons = soup("button") 22 selects = soup("select") 23 text_areas = soup("textAreas") 24 25 return forms, inputs, buttons, selects, text_areas
Searches html for various user input elements.
Returns a tuple where each element is a list of BeautifulSoup Tag elements.
The tuple elements are forms, inputs, buttons, select elements, and text_areas. If an element type was not found, it will be an empty list.
The inputs, buttons, select elements, and text_areas are ones not already found in a form element.