아래 링크 안에 자바 스크립트 테이블을 스크랩하려고합니다. 나는 웹 페이지의 내용을 얻을 때 http://data2.7m.cn/history_Matches_Data/2009-2010/92/en/index.shtmlPython Selenium, 웹 페이지 자바 스크립트 테이블을 스크랩
import codecs
import lxml.html as lh
from lxml import etree
import requests
from selenium import webdriver
import urllib2
from bs4 import BeautifulSoup
URL = 'http://data2.7m.cn/history_Matches_Data/2009-2010/92/en/index.shtml'
profile = webdriver.FirefoxProfile()
profile.set_preference('network.http.max-connections', 30)
profile.update_preferences()
browser = webdriver.Firefox(profile)
browser.get(URL)
content = browser.page_source
soup = BeautifulSoup(''.join(content))
후 나는 축구 라운드의 수를 특정 리그에서 일치 알 필요가있다.
아래의 코드는 유일한 테이블을 찾았습니다. 38 개의 축구 경기 테이블을 모두 얻는 방법을 알고 있습니까? 고맙습니다. 당신 같은 결과를 축적 - 다음 각 클릭 후 ID Match_Table
와 테이블을 긁어 (1 시작할 존재하기 때문에)
# scrap the round of soccer matches
soup.findAll('td', attrs={'class': 'lsm2'})
# print the soccer matches' result of default round, but there have 38 rounds (id from s1 to s38)
print soup.find("div", {"id": "Match_Table"}).prettify()
하지만 잉글랜드 축구 리그의 상당 부분이 폐기되어야하므로 많은 시간이 소요됩니다. 더 좋은 생각이야? :) –