(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"}})


댓글

이 블로그의 인기 게시물

(ElasticSearch) 결과에서 순서 정렬

(네트워크)폴링방식 vs 롱 폴링방식

(18장) WebSocekt과 STOMP를 사용하여 메시징하기