import os, re, sys, urllib2
from bs4 import BeautifulSoup
import lxml
html = urllib2.urlopen("http://www.hoerzu.de/tv-programm/jetzt/")
soup = BeautifulSoup(html, "lxml")
divs = soup.find_all("div", {"class":"block"})
print len(divs)
출력 : 나는 또한 시도BeautifulSoup/lxml : 큰 요소에 문제가 있습니까?
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, re, sys, urllib2
>>> from bs4 import BeautifulSoup
>>> import lxml
>>>
>>> html = urllib2.urlopen("http://www.hoerzu.de/tv-programm/jetzt/")
>>> soup = BeautifulSoup(html, "lxml")
>>> divs = soup.find_all("div", {"class":"block"})
>>> print len(divs)
2
: 같은 결과
divs = soup.find_all(class_="block")
...
그러나이 조건에 맞는 11 개 요소가 있습니다. 그래서 최대 요소 크기 resp 같은 모든 제한이 있습니다. 어떻게 모든 요소를 얻을 수 있습니까? 그것은 나를 위해 1
인쇄 (lxml
사용) 원래의 코드와
import os, re, sys, urllib2
from bs4 import BeautifulSoup
import lxml
html = urllib2.urlopen("http://www.hoerzu.de/tv-programm/jetzt/")
soup = BeautifulSoup(html, "html.parser")
divs = soup.find_all("div", {"class":"block"})
print len(divs)
, 그러나 이것은 11
을 인쇄 :
나는 침대에 가고 싶다고 생각합니다. –
코드에 11 개의 div가 있습니다. – JosefAssad
@JosefAssad와 동일합니다. 첫 코드로 11을 얻고 있습니다. – ton1c