Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.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 I';我试图建立一个网页刮板,现在只能拉一个css元素的地方有81_Python_Web_Web Scraping_Beautifulsoup - Fatal编程技术网

Python I';我试图建立一个网页刮板,现在只能拉一个css元素的地方有81

Python I';我试图建立一个网页刮板,现在只能拉一个css元素的地方有81,python,web,web-scraping,beautifulsoup,Python,Web,Web Scraping,Beautifulsoup,我想拉所有81个元素,但这样一次只能拉一个。该页面是动态的,因此我将有81个以上的元素。该页面还有几个可排序表编号属性,因此我尽量避免使用它,因为beautifulsoup似乎会感到困惑 rreads1 = soup.select('tr.sortableTable-row:nth-child(2) > td:nth-child(3) > span:nth-child(2)') rreads = rreads1[0].get_text() reads.append(rreads)

我想拉所有81个元素,但这样一次只能拉一个。该页面是动态的,因此我将有81个以上的元素。该页面还有几个
可排序表编号
属性,因此我尽量避免使用它,因为beautifulsoup似乎会感到困惑

rreads1 = soup.select('tr.sortableTable-row:nth-child(2) > td:nth-child(3) > span:nth-child(2)')
rreads = rreads1[0].get_text()
reads.append(rreads)

如前所述,改进您的问题并添加

根据提供的信息,您可以循环macthes:

reads = []

for item in soup.select('tr.sortableTable-row:nth-child(2) > td:nth-child(3) > span:nth-child(2)'):
    rreads = item.get_text()
    reads.append(rreads)

帮助我们帮助您-请改进您的问题,以便我们能够重现您的问题。谢谢(URL和一些代码会很酷)