【发布时间】:2013-11-13 08:55:00
【问题描述】:
我将废弃以下链接中的 javascript 表格。 http://data2.7m.cn/history_Matches_Data/2009-2010/92/en/index.shtml
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()
【问题讨论】:
标签: javascript python selenium beautifulsoup