Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.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 findall在find中_Python_Html_Python 3.x_Web Scraping_Beautifulsoup - Fatal编程技术网

python beautifulsoup findall在find中

python beautifulsoup findall在find中,python,html,python-3.x,web-scraping,beautifulsoup,Python,Html,Python 3.x,Web Scraping,Beautifulsoup,我正在尝试获取td类“column-1”中的文本,我遇到了一些问题,因为它没有属性文本-但它显然有属性文本,所以我一定是做错了什么。代码如下: import urllib import urllib.request from bs4 import BeautifulSoup theurl="http://vermontamerican.com/products/standard-drill-bit-extensions/" thepage = urllib.request.urlopen(th

我正在尝试获取td类“column-1”中的文本,我遇到了一些问题,因为它没有属性文本-但它显然有属性文本,所以我一定是做错了什么。代码如下:

import urllib
import urllib.request
from bs4 import BeautifulSoup

theurl="http://vermontamerican.com/products/standard-drill-bit-extensions/"
thepage = urllib.request.urlopen(theurl)
soup = BeautifulSoup(thepage,"html.parser")

for part in soup.find_all('td'),{"class":"column-1"}:
    part1 = part.text
    print(part1)
如果我把第2行去掉,只打印上面的“部分”,我会得到一个结果,但它给出的是所有td,而不仅仅是第1列。 我也试过,但我是新来的,所以我确信这在很多方面都是错误的

import urllib
import urllib.request
from bs4 import BeautifulSoup

theurl="http://vermontamerican.com/products/standard-drill-bit-extensions/"
thepage = urllib.request.urlopen(theurl)
soup = BeautifulSoup(thepage,"html.parser")


for part in soup.find('tbody'),{"class":"row-hover"}:
    for part1 in part.find_all('a'):
        print(part1)

您没有将属性选择字典传递到
find\u all()
函数中。替换:

for part in soup.find_all('td'),{"class":"column-1"}:
与:

现在,您的代码将生成:

17103
17104
17103
17104