회원 로그인
정보기억 정보기억에 체크할 경우 다음접속시 아이디와 패스워드를 입력하지 않으셔도 됩니다.
그러나, 개인PC가 아닐 경우 타인이 로그인할 수 있습니다.
PC를 여러사람이 사용하는 공공장소에서는 체크하지 마세요.
소셜네트워크 서비스를 통해서 로그인하시면 별도의 로그인 절차없이 회원서비스를 이용하실 수 있습니다.


최근 게시물

1.노션에서 작성 중

1.노션에서 작성 중

개편하기 전까지 노션에서 작성 중

2024.04.04//read more

2.ChatGPT

2.ChatGPT

OpenAI로 대규모 언어 모델대화형...

2023.03.16//read more

3.노코딩 게임 엔진 - 빌..

3.노코딩 게임 엔진 - 빌..

빌드 지원안드로이드iOS윈도우즈특이사...

2023.03.14//read more

4.(완료) 미접속 회원 정..

4.(완료) 미접속 회원 정..

[완료] 36명의 회원을 정리하였습니...

2023.02.16//read more

5.매뉴얼 플러스 - 전자제..



안정적인 DNS 서비스 DNSEver
DNS Powered by DNSEver.com


BeautifulSoup html 파싱

푸딩뱃살 | 2014.04.21 17:42 | 조회 7841
| BeautifulSoup html 파싱

HTML과 XML 파일로부터 데이터를 뽑아내기 위한 파이썬 라이브러리 

#3.x일 때
from BeautifulSoup import BeautifulSoup
# 4.x일 때
# from bs4 import BeautifulSoup
import urllib2

url_ = 'http://주소'
page_ = urllib2.urlopen(url_) #웹 페이지 오픈
soup_ = BeautifulSoup(page_.read()) #웹 페이지 리딩
elements_ = soup_.findAll('태그명',{'클래스명':'추출명'}) #태그안에 추출 클래스 파싱
....
#추출로 활용

 Python 2.6에서 BeautifulSoup 사용 시 오류가 나는데 아직 파악 중
해결http://dvframes.com/rb/?r=home&c=study/programming&uid=1425


Warning (from warnings module):
  File "C:\Python26\lib\site-packages\bs4\builder\_htmlparser.py", line 149
    "Python's built-in HTMLParser cannot parse the given document. This is not a bug in Beautiful Soup. The best solution is to install an external parser (lxml or html5lib), and use Beautiful Soup with that parser. See http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser for help."))
RuntimeWarning: Python's built-in HTMLParser cannot parse the given document. This is not a bug in Beautiful Soup. The best solution is to install an external parser (lxml or html5lib), and use Beautiful Soup with that parser. See http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser for help.

Traceback (most recent call last):
  File "\경로\ex.py", line 98, in <module>
    legoCartOuput(urlList_)
  File "\경로\ex.py", line 75, in legoCartOuput
    legoCartCheck(inUrl_)
  File "\경로\ex.py", line 55, in legoCartCheck
    soup_ = BeautifulSoup(page_.read())
  File "C:\Python26\lib\site-packages\bs4\__init__.py", line 172, in __init__
    self._feed()
  File "C:\Python26\lib\site-packages\bs4\__init__.py", line 185, in _feed
    self.builder.feed(self.markup)
  File "C:\Python26\lib\site-packages\bs4\builder\_htmlparser.py", line 150, in feed
    raise e
HTMLParseError: bad end tag: u'</scr"+"ipt>', at line 5707, column 78

285개(12/15페이지)
프로그래밍
번호 제목 글쓴이 조회 날짜
65 [Python] pygame 모듈로 사운드 출력 첨부파일 푸딩뱃살 9503 2014.05.13 18:32
64 [Python] Python 중복 실행 방지 - setuptools, tendo 첨부파일 푸딩뱃살 8087 2014.05.08 14:56
63 [Python] Python 메일 보내기 첨부파일 푸딩뱃살 4795 2014.05.08 13:53
62 [Python] BeautifulSoup 파싱 에러 푸딩뱃살 7154 2014.04.22 09:59
>> [Python] BeautifulSoup html 파싱 푸딩뱃살 7842 2014.04.21 17:42
60 [Python] 웹 파싱 모듈 BeautifulSoup 설치 첨부파일 푸딩뱃살 5804 2014.04.21 11:23
59 [C#] C# 예제 푸딩뱃살 2743 2014.04.19 22:24
58 [C#] 제어문 - switch~case문 푸딩뱃살 3288 2014.04.03 19:28
57 [C#] 루프 중단 break, 조건으로 이동 continue 푸딩뱃살 7890 2014.03.10 01:32
56 [C#] 제어문 - while문 / do~while문 푸딩뱃살 3204 2014.02.17 14:18
55 [C#] 제어문 - foreach문 푸딩뱃살 3303 2014.02.17 13:58
54 [PHP] PHP 2GB 대용량 업로드 푸딩뱃살 3693 2014.02.13 14:04
53 [C#] 제어문 - for문 푸딩뱃살 2934 2014.02.13 10:36
52 [C#] 제어문 - if문 (복수 수행) 푸딩뱃살 3668 2014.02.09 01:31
51 [C#] 제어문 - if문 푸딩뱃살 3111 2014.02.05 14:01
50 [C#] 형의 변환 푸딩뱃살 2815 2014.01.21 13:54
49 [C#] 연산자의 우선순위 푸딩뱃살 2975 2014.01.20 16:24
48 [C#] 논리 연산자 푸딩뱃살 2728 2014.01.14 14:29
47 [C#] 논리형, 조건 연산자 푸딩뱃살 2841 2014.01.14 10:12
46 [C#] C# for Notepad++ plugin 첨부파일 푸딩뱃살 3494 2014.01.07 10:34