Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用BeautifulSoup刮取特定表行_Python_Html_Selenium_Beautifulsoup - Fatal编程技术网

Python 使用BeautifulSoup刮取特定表行

Python 使用BeautifulSoup刮取特定表行,python,html,selenium,beautifulsoup,Python,Html,Selenium,Beautifulsoup,我试图从我的基本url页面(图中标记为蓝色圆圈)中划出特定的行。页面源代码在另一张图片中 我的目标是获取那些标记,但不知何故,我的代码无法获取它们 我的代码: from bs4 import BeautifulSoup from selenium import webdriver import requests, csv, re, pandas, numpy base_url = "http://www.basket.fi/sarjat/ottelu/?game_id=3502579&

我试图从我的基本url页面(图中标记为蓝色圆圈)中划出特定的行。页面源代码在另一张图片中

我的目标是获取那些标记,但不知何故,我的代码无法获取它们

我的代码:

from bs4 import BeautifulSoup
from selenium import webdriver
import requests, csv, re, pandas, numpy

base_url = "http://www.basket.fi/sarjat/ottelu/?game_id=3502579&season_id=93783&league_id=4+"+"#mbt:2-400$t&0=1"
browser = webdriver.PhantomJS()
browser.get(base_url)
table = BeautifulSoup(browser.page_source, 'lxml')

for data in table.find_all("tr",{"class":"row2"}):
    print(data.find("td").text)


通常,您可以按属性选择html元素,但对于本文档,“class”属性没有多大帮助,因为同一个类中还有许多其他“tr”标记

在这种情况下,您可以使用列表索引来选择标记

for td in table.find_all("tr", {"class":"row2"})[25].find_all('td')[1:]:
    print(td.get_text(strip=True))

问题是什么,请解释一下?@TarunLalwani我的代码没有得到我想要的标记。可能在粘贴箱或原始url中获得HTML?原始url: