酷
代
码
酷代码
在线工具
仪表盘
清爽模式
搜索模式
协作模式
证件照自拍
证件照换底色
关于
new
设置
菜单
字节-豆包AI
阿里-通义AI
讯飞-星火AI
百度-文心AI
GPT-代码AI
写作助手
论文助手
问AI
任务一:采集唐诗三百首内容 python import requests from bs4 import beautifulsoup import pandas as pd url = "https://so.gushiwen.cn/gushi/tangshi.aspx" response = requests.get(url) soup = beautifulsoup(response.text, "html.parser") poems = [] for poem in soup.find_all("div", class_="item"): title = poem.find("h1").text.strip() content = poem.find("p").text.strip() author = poem.find("span", class_="author").text.strip() poem_type = "唐诗" poems.append(
服务器繁忙,请稍后再试 [2024-06-24 15:46:11 | GPT-代码助手 | 15字解答]
相关提问
如何隐藏我的提问?
任务一:采集唐诗三百首内容 python import requests from bs4 import beautifulsoup import pandas as pd url = "https://so.gushiwen.cn/gushi/tangshi.aspx" response = requests.get(url) soup = beautifulsoup(response.text, "html.parser") poems = [] for poem in soup.find_all("div", class_="item"): title = poem.find("h1").text.strip() content = poem.find("p").text.strip() author = poem.find("span", class_="author").text.strip() poem_type = "唐诗" poems.append((GPT-代码助手 | 15字解答 | 2024-06-24 15:46:11)
55
import requests from bs4 import beautifulsoup import pandas as pd url = "https://so.gushiwen.cn/gushi/tangshi.aspx" response = requests.get(url) soup = beautifulsoup(response.text, 'html.parser') # 提取所需数据 poems_data = [] for row in soup.find_all('tr', class_='tlist')[1:]: cols = row.find_all('td') type_ = cols.text.strip() title = cols.a.text.strip() content = cols.text.replace('\n', '').replace('\t', '') author = cols.text.strip() poems_data.append([type_, title, conte(GPT-代码助手 | 120字解答 | 2024-06-24 02:04:56)
85
import requests from bs4 import beautifulsoup def get_poems(): url = "https://so.gushiwen.cn/gushi/tangshi.aspx" response = requests.get(url) response.encoding = "utf-8" soup = beautifulsoup(response.text, "html.parser") # 获取所有的诗列表 poem_list = soup.find_all("div", class_="typecont") poems = [] # 遍历诗列表,提取相关信息 for poem in poem_list: # 获取诗类型 poem_type = poem.find_previous_sibling("div", class_="bookml").find("span").text # 获取诗题目(GPT-代码助手 | 316字解答 | 2024-06-24 00:59:22)
62
import requests from bs4 import beautifulsoup # 爬取唐诗三百首的内容 def scrape_data(): url = "https://so.gushiwen.cn/gushi/tangshi.aspx" headers = { "user-agent": "mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/89.0.4389.82 safari/537.36" } response = requests.get(url, headers=headers) if response.status_code == 200: soup = beautifulsoup(response.text, "html.parser") content_divs = soup.find_all('div', c(GPT-代码助手 | 443字解答 | 2024-06-24 01:16:00)
59
为了完成上述任务,我将分步骤提供代码。首先,我会提供任务一的代码,用于从网站采集唐诗三百首的内容并保存到txt文件中。 ### 任务一:采集唐诗三百首内容 ```python import requests import re # 定义爬取函数 def fetch_poems(url): response = requests.get(url) poems_info = re.findall( r'<a href="(.*?)"\s*target="_blank" title="(.*?)">\s*<span\s*style="font-size:16px;">(.*?)</span>\s*</a>', response.text, re.s ) poems = [] for info in poems_info: poem_url = "https://so.gushiwen.cn" + info[0] poem_response = requests(讯飞-星火认知 | 208字解答 | 2024-06-23 11:07:39)
53
void searchlearningcontent(string keyword) { for (const auto& content : learningcontents) { if (content.title.find(keyword) != string::npos || content.description.find(keyword) != string::npos) { cout << "title: " << content.title << endl; cout << "description: " << content.description << endl; cout << "priority: " << content.priority << endl; cout << "---------------------------" << endl; }是什么意思(GPT-代码助手 | 158字解答 | 2024-07-01 21:25:40)
54
帮我美化和优化以下代码:<!--#include file="inc/conn.asp"--> <!--#include file="inc/config.asp"--> <% dim verifycode,verifycode2 if verifycode<>verifycode2 then response.write"location.href='index.asp'</script>" response.end() founderr=true else %> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3c.org/tr/1999/rec-html401-19991224/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><%=sitename%></title> <meta http-equiv=content-type content="text/html; charset=gb(GPT-代码助手 | 45字解答 | 2024-07-11 14:16:55)
59
import javax.swing.*; import java.awt.*; import java.awt.datatransfer.clipboard; import java.awt.datatransfer.stringselection; import java.awt.datatransfer.transferable; import java.awt.event.*; import java.io.*; import java.nio.file.files; import java.nio.file.path; import java.nio.file.paths; import java.time.localdatetime; import java.util.hashmap; import java.util.list; import java.util.map; import java.util.random; public class copy { static private final jtextarea textarea = new jtext(GPT-代码助手 | 1497字解答 | 2024-08-25 09:40:33)
26
有如下一段html代码,请用css实现鼠标移入a标签,自动隐藏class="api-name-div"的div <a href="#" class="api-block"> <img src="../image/muwu.jpg"> <div class="api-name-div">幸福就是可以一起睡觉</div> <div class="api-edit-div">编辑</div>(阿里-通义千问 | 181字解答 | 2023-10-26 09:52:31)
136
# -*- coding:utf-8 -*- # file_name vip_video_final.py __author__ = 'charon' import tkinter as tk import webbrowser from tkinter import ttk from tkinter.messagebox import showwarning import requests from bs4 import beautifulsoup txt_list = [] mapping = dict() def center_window(window, w, h): # 获取屏幕 宽、高 ws = window.winfo_screenwidth() hs = window.winfo_screenheight() # 计算 x, y 位置 x = (ws / 2) - (w / 2) y = (hs / 2) - (h / 2) window.geometry('%dx%d+%d+%d' % ((字节-豆包 | 314字解答 | 2024-08-02 14:49:22)
52
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script> function getnowdate(){ var today=new date(); var d=new array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); var nowdate= ""; nowdate = showlocale();// 获取当前时间 年月日 时分秒 nowdate = nowdate+ " "+ d[today.ge(字节-豆包 | 284字解答 | 2024-08-06 13:24:39)
41
<a href="#" class="api-block"> <img src="../image/muwu.jpg"> <div class="api-name-div">幸福就是可以一起睡觉</div> <div class="api-edit-div">编辑</div> </a>(阿里-通义千问 | 182字解答 | 2023-10-26 09:46:09)
103
我的问AI |
我的收藏
暂无