(python) BeautifuSoup library find() and findAll() (Crawling)

The most usage of methods are find() and findAll() in BeautifulSoup.

If you use these methods, you can filter tags according to various attributes in HTML page.

The next two methods show what parameters

findAll(tag, attributes, recursive, text, limit, keywords)

find(tag, attributes, recursive, text, keywords)

the paramteres are mostly same in two methods.

First, tag parameter can be string type or list type;

Second, attributes parameters can be dictionary type and find a equivalent tag of them

Third, recursive type is boolean. if it is True value, findAll()  search for children and children of children. If it is Fals value. it will find only first tag.(Default is True)

Fourth, It is different that text parameter is not a tag attribute but text contents.
for example, it can show how many "the clothes",
(.findAll(text = "the clothes")

and the next is
it returns both James tag and Marry tag.

.findAll("span", {"class":{"green", "red"}})


댓글

이 블로그의 인기 게시물

(Garbage Collection) Old Area의 Concurrent Mark-sweep 알고리즘

(Pytorch) DataLoder 클래스

(데이터베이스) HAVING절과 WHERE 절의 차이