티스토리 뷰
bs4는 파이썬의 기본 파서도 지원하지만 외부의 서드파티 파서도 지원한다.
lxml, html5lib 등의 파서를 지원한다.
다음의 오류는 파서를 지정하지 않아서 발생하는 오류이다.
파이썬 기본 파서를 사용하려면, "html.parser"를 지정하면 된다.
lxml 을 이용하기 위해서는 pip를 이용하여 설치를 해야 한다.
설치는 "pip install lxml" 으로 하면된다.
UserWarning: No parser was explicitly specified, so I'm using the best
available HTML parser for this system ("html.parser"). This usually isn't a
problem, but if you run this code on another system, or in a different
virtual environment, it may use a different parser and behave differently.
To get rid of this warning, change this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "html.parser")
bs = BeautifulSoup(r.text, "html.parser")
bs = BeautifulSoup(r.text, "lxml")
파서 인스톨 - https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser
'python' 카테고리의 다른 글
[python] 반복적인 입력에는 input() 대신 sys.stdin.readline 로 변경 (0) | 2018.06.18 |
---|---|
[python] 현재폴더의 파일이름, 파일명 일괄 변경하기 (2) | 2018.04.23 |
[python] multiprocessing 을 이용한 스레드 처리 (0) | 2017.12.07 |
[python] GIL(Global Interpreter Lock) (0) | 2017.11.21 |
[python] 문자열을 효율적으로 concat 하는 방법 (0) | 2017.02.22 |
- Total
- Today
- Yesterday
- 알고리즘
- bash
- 오류
- Python
- 하이브
- 하둡
- 다이나믹
- 백준
- Linux
- AWS
- Tez
- yarn
- 정올
- Hadoop
- airflow
- 파이썬
- build
- HIVE
- S3
- emr
- SPARK
- ubuntu
- nodejs
- HDFS
- oozie
- mysql
- hbase
- error
- java
- SQL
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |