第四课,这段代码在扇贝里可以运行,为什么在vscode运行不了?

您所在的位置:网站首页 vscode没有运行按钮 第四课,这段代码在扇贝里可以运行,为什么在vscode运行不了?

第四课,这段代码在扇贝里可以运行,为什么在vscode运行不了?

2022-05-14 17:29| 来源: 网络整理| 查看: 265

import requests import time from bs4 import BeautifulSoup def get_douban_books(url): headers ={ 'user-agent':'Mozilla/5.0(Macintosh;IntelMacOSX10_13_6)AppleWebKit/537.36(KHTML,likeGecko)Chrome/76.0.3809.132Safari/537.36' } res = requests.get(url,headers=headers) soup = BeautifulSoup(res.text,'html.parser') items = soup.find_all('div',class_ = 'p12') for i in items: tag = i.find('a') name = tag['title'] link = tag['href'] print(name,link) url = 'https://book.douban.com/top250?start={}' urls =[url.format(num * 25)for num in range(10)] for i in urls: get_douban_books(i) time.sleep(1)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3