개발자/파이썬 Python

파이썬 lxml 패키지 설치 해결~ 이게 또 libxml2 와 연관이 있나.

지구빵집 2016. 11. 30. 19:52
반응형




웹 크로울러 예제가 올라와서 한 번 해본다고 하는데

http://creativeworks.tistory.com/entry/PYTHON-3-Tutorials-24-%EC%9B%B9-%ED%81%AC%EB%A1%A4%EB%9F%AClike-Google-%EB%A7%8C%EB%93%A4%EA%B8%B0-1-How-to-build-a-web-crawler


위에서 실습한 소스코드는 아래에 있다.


import requests
from bs4 import BeautifulSoup

def spider(max_pages):
page = 1
while page < max_pages:
url = 'http://creativeworks.tistory.com/' + str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, 'lxml')
for title_list in soup.find_all(['h3','class']):
title = title_list.text
href = url
print(href)
print(title)
page += 1

spider(10)


결과 화면은 아래와 같다. 싸이트를 아주 잘 읽어서 보여준다.


C:\Python34\python.exe M:/Dev-python/webcrawl.py

http://creativeworks.tistory.com/1

[Ruby] Install nokogiri on Ubuntu.

http://creativeworks.tistory.com/2

[Bash] Photos, Files auto sorting script on Windows,Linux,Mac by dates

http://creativeworks.tistory.com/3

[Ruby] Node.js를 이용하여 웹 사이트 데이터 가져오기(web scraping, Phantomjs)

http://creativeworks.tistory.com/3

Phantomjs로 웹사이트 데이터 가져오기

http://creativeworks.tistory.com/3

Phantomjs를 node에서 사용하기

http://creativeworks.tistory.com/4

[python2] scapy 기초

http://creativeworks.tistory.com/4

scapy 기초.

http://creativeworks.tistory.com/5

[python2] 파이썬의 멀티쓰레딩과 멀티프로세싱.

http://creativeworks.tistory.com/5

파이썬의 멀티쓰레딩과 멀티프로세싱.

http://creativeworks.tistory.com/6

데이터마이닝, 머신러닝 공부관련

http://creativeworks.tistory.com/7

151014 Democratic Debate Turns Hillary Clinton’s Way After Months of Difficulties

http://creativeworks.tistory.com/8

Hacking for Security, and Getting Paid for It

http://creativeworks.tistory.com/9

El Capitan 10.11.1 Beta and Public Beta Release on 151015. 엘 케피탄 10.11.1 네번째 릴리즈


Process finished with exit code 0




lxml  패키지가 설치하는데 문제가 생겨 헤메다가 해결했다.


lxml 이라는 파이썬 관련 libxml2 windows install 패키지를 설치해야 한다. 


다운로드 URL : https://pypi.python.org/pypi/lxml


32비트 번전이라서 다운 받은 파일은 lxml-3.5.0.win32-py3.4.exe (md5) 이 파일을 다운 받았고

실행해서 설치가 되니 잘 되었다.





반응형