我要去掉下面链接里面的javascript表。 http://data2.7m.cn/history_Matches_Data/2009-2010/92/en/index.shtmlPython硒,刮网页javascript表
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个足球比赛的表?谢谢。
# 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()
但似乎时间消耗,因为有相当多的英国足球联赛需要报废。有什么更好的想法:) –