标签:xml (1)

为什么用BeautifulSoup提取xml的link标签中的url总为空呢

为什么用BeautifulSoup提取xml的link标签中的url总为空呢

废话少说

闲言少叙,直接上代码:
#!/usr/bin/env python3
# coding=utf-8


import requests from bs4 import BeautifulSoup

def get_soup(): url = 'https://www.solidot.org/index.rss' rss_xml = requests.get(url).text soup = BeautifulSoup(rss_xml, 'html5lib') return soup

def get_mail_body(): contents = get_soup().select('item')[0:9] contents_list = [] for c in contents: title = c …
阅读更多