2017-11-25 7 views

답변

1

구문 분석은 어떻게됩니까? PyPI's official webpage? 그렇게하려면 requests 패키지를 사용하여 페이지 콘텐츠를 가져오고 페이지에서 BeautifulSoup 패키지를 사용하여 원하는 콘텐츠를 추출하십시오.

이것은 추출중인 the content입니다. 아직 requests 패키지와 beautifulsoup4 패키지를 설치해야합니다.

pip install requests 
pip install beautifulsoup4 

요청 및 구문 분석 :

import requests 
from bs4 import BeautifulSoup 

response = requests.get("https://pypi.python.org/pypi") 
soup = BeautifulSoup(response.content, 'html.parser') 
print(soup.select('div.section > p > strong')[0].get_text())