cndotaercrazybm
2021-06-19 15:35
采纳率: 85.7%
浏览 345

怎么二次提取<class 'bs4.element.ResultSet'>类型文件中的内容

我将网页中想要的部分提取成这种类型文件后,怎么二次提起,关于这种类型的语法该去看什么

import requests
import re
import os
from lxml import etree
from bs4 import BeautifulSoup
if __name__ == "__main__":

    # 爬取页面源码数据
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'
    }   # UA伪装
    url = 'https://item.jd.com/100016034380.html'
    page = requests.get(url=url,headers = headers)
    page_text = page.text
    soup = BeautifulSoup(page_text,"html.parser")
    info_list = soup.find_all("ul",{"class":"parameter2 p-parameter-list"})
    choose1_list = soup.find_all("div",{"id":"choose-attr-1"})
    choose2_list = soup.find_all("div",{"id":"choose-attr-2"})
    choose3_list = soup.find_all("div",{"id":"choose-attr-3"})
    print(type(info_list))
    print(choose1_list)
    print(choose2_list)
    print(choose1_list)
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题