2017-11-08 1 views
0
import requests 
from bs4 import BeautifulSoup 

url= requests.get('https://angel.co/companies').text 
soup= BeautifulSoup(url, 'lxml') 

for div in soup.find_all("div", class_="name"): 
    print(div.text) 

회사 명을 인쇄하고 싶지만 아무 것도 인쇄하지 않습니다.각도 목록 데이터 스크랩

+0

해당 웹 사이트의 콘텐츠가 동적으로로드되기 때문에 API를 사용하여 '게시'요청을 수행하지 않는 한 요청을 포착 할 수 없습니다. 해당 웹 페이지의 컨텐츠를 얻으려면 셀렌과 같은 브라우저 시뮬레이터를 선택해야합니다. – SIM

답변

0

@Shahin이 그의 의견에서 언급했듯이 Selenium을 사용하면 웹 페이지의 콘텐츠를 얻는 것이 더 나을 것입니다. 로드하려는 URL을 지정하면 페이지 맨 아래에 스크롤 기능을 구현할 것입니다. (저는 angel.co에 꽤 익숙하며 웹 사이트에는 많은 검색어가 포함되어 있습니다).

from bs4 import BeautifulSoup 
from selenium import webdriver 

link = 'Specify your link here' 
driver.get(link) 

'Enter code here to support scrolling through the webpage' 

soup = BeautifulSoup(driver.page_source, 'html.parser') 
driver.quit() 
0
from selenium import webdriver 
from bs4 import BeautifulSoup 

link = 'https://angel.co/companies?locations[]=393668-New+Delhi,+IN' 

driver = webdriver.Chrome() 
for url in [link.format(i) for i in range(1,6)]: 
    driver.get(url) 
    soup = BeautifulSoup(driver.page_source, 'html.parser') 
    for items in soup.select('.name'): 
     print(name) 
driver.quit() 

이 프로그램 실행을하지만 어떤 이름을 인쇄 doesno't : 나는 셀레늄에 대한 드라이버를 시작하는 당신을 떠날 것이다.