酷代码
AI
首页
AI工具箱
在线工具
证件照自拍
证件照换底色
关于
设置
登录/注册
菜单
全部AI
/
热门
/ AI写代码神器
服务商
DeepSeek
字节豆包
阿里通义
讯飞星火
百度文心
GPT
开启上下文联想
更多选项
快捷项
语言方向:不限
语言方向:Java
语言方向:C#
语言方向:Python
语言方向:C++
语言方向:C
语言方向:JavaScript
语言方向:Go
语言方向:Ruby
语言方向:Swift
语言方向:R
语言方向:PHP
语言方向:CSS
语言方向:TypeScript
语言方向:Shell
语言方向:Scala
语言方向:Maxscript
语言方向:html
系统环境:不限
系统环境:Windows
系统环境:Linux
系统环境:Mac
其他AI
AI写代码神器
AI问答
AI新闻评论
AI摘要生成
AI高端主持词
AI工作总结报告
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 | AI写代码神器 | 15点数解答]
相关提问
如何隐藏我的提问?
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((15点数解答 | 2024-06-24 15:46:11)
177
AI写代码神器
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 # 获取诗题目(316点数解答 | 2024-06-24 00:59:22)
147
AI写代码神器
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(120点数解答 | 2024-06-24 02:04:56)
175
AI写代码神器
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(443点数解答 | 2024-06-24 01:16:00)
165
AI写代码神器
def fill_and_submit_form(row): print("填充表单并提交...") wait = webdriverwait(driver, 5) # 增加等待时间 try: product_name_input = wait.until(ec.presence_of_element_located((by.xpath, '//*[@id="wcontentpanel"]/div[3]/div/div[2]/form/div[1]/div[3]/div/div/div[1]/input'))) product_category_dropdown = wait.until(ec.element_to_be_clickable((by.xpath, '//*[@id="wcontentpanel"]/div[3]/div/div[2]/form/div[1]/div[4]/div/div/div/span/span/div/div[1]'))) time.sleep(2) # 等待完成(361点数解答 | 2024-11-11 21:56:42)
76
AI写代码神器
为了完成上述任务,我将分步骤提供代码。首先,我会提供任务一的代码,用于从网站采集唐诗三百首的内容并保存到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)
142
AI写代码神器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>2048 Game</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <h1>2048</h1> <button id="newGameButton">New Game</button> <p>Score: <span id="score">0</span></p> </header> <div id="grid-container"> <div class="grid-cell" id="grid-cell-0-0"></div> <div class="grid-cell" id="grid-cell-0-1"></div> <div class="grid-cell" id="grid-cell-0-2">(138点数解答 | 2025-03-05 15:45:36)
158
AI写代码神器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>2048 Game</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <h1>2048</h1> <button id="newGameButton">New Game</button> <p>Score: <span id="score">0</span></p> </header> <div id="grid-container"> <div class="grid-cell" id="grid-cell-0-0"></div> <div class="grid-cell" id="grid-cell-0-1"></div> <div class="grid-cell" id="grid-cell-0-2">(117点数解答 | 2025-03-11 00:06:25)
57
AI写代码神器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>2048 Game</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <h1>2048</h1> <button id="newGameButton">New Game</button> <p>Score: <span id="score">0</span></p> </header> <div id="grid-container"> <div class="grid-cell" id="grid-cell-0-0"></div> <div class="grid-cell" id="grid-cell-0-1"></div> <div class="grid-cell" id="grid-cell-0-2">(201点数解答 | 2025-04-19 11:50:42)
31
AI写代码神器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>2048 Game</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <h1>2048</h1> <button id="newGameButton">New Game</button> <p>Score: <span id="score">0</span></p> </header> <div id="grid-container"> <div class="grid-cell" id="grid-cell-0-0"></div> <div class="grid-cell" id="grid-cell-0-1"></div> <div class="grid-cell" id="grid-cell-0-2">(181点数解答 | 2025-04-29 20:58:02)
13
AI写代码神器
爬取二手房信息包括卖点 楼盘 地址 户型 建筑面积 所在楼层 建造年代 单价网址为 https://dalian.anjuke.com/sale/ 写一下他的解析函数 可以爬取到数据 仿照如下函数格式写 def parser(html): #解析函数 doc=etree.html(html) #html转换为soup对象 out_list=[] for row in doc.xpath("//div[@id='content']//li"): #书名 title=row.xpath(".//h2/a/text()")[0].strip() #评分 score=row.xpath(".//p[@class='rating']/span[2]/text()")[0].strip() #info为作者、出版社、出版日期的列表,通过/分隔 info=row.xpath(".//p[@class='color-gray']/text()")[0].strip().split((854点数解答 | 2024-11-02 08:56:33)
93
AI写代码神器
import openpyxl import smtplib import imaplib import email import json import os import re from bs4 import BeautifulSoup from fastapi import FastAPI, Form from openpyxl.styles import Alignment from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.header import decode_header from email import encoders import pandas as pd app = FastAPI() RECEIVER_EMAILS = { 0: "yundongshijie001@protonmail.com", 1: "xiaobudian001@protonmail.com" } email_address = "(182点数解答 | 2025-04-12 00:49:09)
29
发送