Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.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 web抓取时的AttributeError_Python_Web Scraping_Beautifulsoup - Fatal编程技术网

Python web抓取时的AttributeError

Python web抓取时的AttributeError,python,web-scraping,beautifulsoup,Python,Web Scraping,Beautifulsoup,我的错误回溯如下: AttributeError:ResultSet对象没有属性“find”。 您可能将项目列表视为单个项目。 当您打算调用find()时,是否调用了find_all()? 我的代码如下: 为True时: response=requests.get(url) 回应 data=response.text soup=BeautifulSoup(数据,'html.parser') api=soup.find_all('tr',{“class”:“奇数视图行优先”}) 对于api中的a

我的错误回溯如下:

AttributeError:ResultSet对象没有属性“find”。
您可能将项目列表视为单个项目。
当您打算调用find()时,是否调用了find_all()?
我的代码如下:

为True时:
response=requests.get(url)
回应
data=response.text
soup=BeautifulSoup(数据,'html.parser')
api=soup.find_all('tr',{“class”:“奇数视图行优先”})
对于api中的api:
name=api.find('td',{“class”:“views-field-views-field-pw-version-title”})。文本
des=api.find('td',{'class':'views-fieldviews-field search-api摘录视图field-field-api description hidden xs visible md visible sm col-md-8'})。文本
category=api.find('td',{'class':'views-field-views-field-article-primary-category')。文本
link=api.find('a',{'class':'views-fieldviews-field-pw-version-title')).get('href')
打印('名称:',名称,'\n说明:',des,'\n类别,'\nLink',链接)
url_tag=soup.find('a',{'title':'Go to next page'})
如果url_tag.get('href'):
url=url\u tag.get('href')
打印(url)
其他:
打破

下的
用于
循环。将
api
更改为
api
您从该错误消息中了解/不了解什么?这是否回答了您的问题?还有一些:,
from bs4 import BeautifulSoup
import requests
import pandas as pd
url="https://www.programmableweb.com/category/all/apis"
while True:
    response= requests.get(url)
    response    
    data=response.text
    soup= BeautifulSoup(data,'html.parser') 
    apis=soup.find_all('tr',{"class":["odd","even"]})

    for api in apis:
        name_tag= api.find('td',{"class":"views-field views-field-pw-version-title"})
        name=name_tag.text if name_tag else 'na'
        des_tag=api.find('td',{'class':'views-field views-field-search-api-excerpt views-field-field-api-description hidden-xs visible-md visible-sm col-md-8'})
        des=des_tag.text if des_tag else 'na'
        category_tag=api.find('td',{'class':'views-field views-field-field-article-primary-category'})
        category=category_tag.text if category_tag else 'na'
        link_tag= api.find('a',{'class':'views-field views-field-pw-version-title'})
        link=link_tag.get('href') if link_tag else 'na'
        print('Name:',name,'\nDescription:', des ,'\nCategory:', category ,'\nLink:', link)
    url_tag=soup.find('a',{'title':'Go to next page'})
    if url_tag.get('href'):
        url=url+url_tag.get('href')
    else:
        break