2016-09-20 7 views
0

새로운 웹 스크래핑과 Restaurant Detail Form의 모든 내용을 스크랩하여 더 이상 스크래핑을 진행할 수 없습니다. 결과는 빈리스트이므로Python 3.5.2 웹 스크래핑 - 목록이 범위를 벗어남

import requests 
from bs4 import BeautifulSoup 
import urllib 

url = "https://www.foodpanda.in/restaurants" 
r=requests.get(url) 
soup=BeautifulSoup(r.content,"html.parser") 
print(soup.find_all("Section",class_="js-infscroll-load-more-here")[0]) 
+0

무엇이 문제입니까? –

+0

IndexError : index index of range 로 오류가 발생했습니다. – aenish

+0

추적에 대한 자세한 설명을 게시하십시오. 그리고 그 오류가 발생하면'soup.find_all ("Section", class _ = "js-infscroll-load-more-here")'는 빈 목록입니다. –

답변

0

문제는 soup.find_all("Section",class_="js-infscroll-load-more-here"‌​) 대한 인덱스 0에서 요소로 액세스한다.

section = soup.find_all("section",class_="js-infscroll-load-more-here")[0] 

만 당신은 또한 찾을 수 있습니다 하나가 있기 때문에 :

0

HTML 심지어 소스 자체가 섹션하지 소문자 s의 이다 상관없이 더 대문자 태그의 개념과가 없습니다 :

section = soup.find("section",class_="js-infscroll-load-more-here") 

두 가지 모두 당신이 찾고있는 것을 발견 할 것입니다.