为什么我在这里遇到类型错误?
import csv
import requests
page = requests.get("URL.com")
from bs4 import BeautifulSoup
soup = BeautifulSoup(page.content, 'html.parser')
listitems = {}
for a in soup.select('a.sitemaplink', href=True):
listitems.update({a.text:a['href']})
for b in listitems.values:
newpage = requests.get("URL.com"+b)
我需要能够访问现在作为值存储在列表项中的链接
答案 0 :(得分:0)
您需要使用listitems.values()
而不是listitems.values
对字典的值进行迭代,因为您无法对内置函数进行迭代,这就是您所看到的错误
for b in listitems.values():
newpage = requests.get("URL.com"+b)