https://www.pixiv.net/
时间: 2023-10-05 17:07:18 浏览: 1251
I'm sorry, as an AI language model, I do not have the capability to access external links or websites. However, I can provide you with information about Pixiv. Pixiv is a Japanese online community for artists where they can share their artwork and interact with other artists. It is a popular platform for manga and anime artists and has a large following in Japan and around the world. Users can also purchase prints and merchandise featuring their favorite artwork.
相关问题
pixiv上爬取图片存到mariadb数据库
要实现这个功能,你需要掌握以下技能:
1. Python 爬虫技术
2. Mariadb 数据库操作技术
下面是一个简单的步骤:
1. 安装 Python 客户端和 Mariadb 数据库。
2. 在 Mariadb 中创建一个名为 pixiv 的数据库,然后创建一个名为 images 的表,该表包含以下字段:id(自增长)、title、url、tags 和创建时间。你可以使用如下 SQL 语句进行创建:
```
CREATE DATABASE IF NOT EXISTS pixiv;
USE pixiv;
CREATE TABLE IF NOT EXISTS images (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
url VARCHAR(255) NOT NULL,
tags VARCHAR(255) DEFAULT '',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
```
3. 安装必要的 Python 库,包括 requests 和 pymysql 库。
4. 编写 Python 爬虫代码。你可以使用 requests 库获取 Pixiv 网站上的图片信息,然后将相关信息存储到 Mariadb 数据库中。下面是一个示例代码:
```
import requests
import pymysql
# 连接数据库
conn = pymysql.connect(host='localhost', user='root', password='password', database='pixiv')
# 获取图片信息
url = 'https://www.pixiv.net/ajax/search/artworks/%E7%8C%AB%E3%80%80OR%E3%83%8D%E3%82%B3?word=%E7%8C%AB%E3%80%80OR%E3%83%8D%E3%82%B3&order=date_d&mode=all&p=1&s_mode=s_tag&type=all'
headers = {
'Referer': 'https://www.pixiv.net/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
response = requests.get(url, headers=headers)
json_data = response.json()
works = json_data['body']['illustManga']['data']
# 将图片信息存储到数据库中
for work in works:
title = work['title']
url = work['url']
tags = ','.join(work['tags'])
cursor = conn.cursor()
sql = "INSERT INTO images (title, url, tags) VALUES (%s, %s, %s)"
cursor.execute(sql, (title, url, tags))
conn.commit()
cursor.close()
# 关闭数据库连接
conn.close()
```
5. 运行 Python 爬虫代码,将图片信息存储到 Mariadb 数据库中。
以上就是将 Pixiv 上的图片信息存储到 Mariadb 数据库的简单步骤。当然,你可以根据自己的需求进行更改和优化。
用Python写一个爬取pixiv网站图片的爬虫
好的,以下是一个简单的爬取pixiv网站图片的Python爬虫:
```python
import requests
from bs4 import BeautifulSoup
import os
# 图片保存路径
save_path = "./pixiv_images"
# 爬取页面的URL
url = "https://www.pixiv.net/ranking.php"
# 请求头信息
headers = {
"Referer": "https://www.pixiv.net/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"}
# 发送请求,获取页面内容
response = requests.get(url, headers=headers)
# 解析HTML
soup = BeautifulSoup(response.text, "html.parser")
# 获取图片链接
img_tags = soup.select("img[src^='https://i.pximg.net']")
# 创建文件夹
if not os.path.exists(save_path):
os.makedirs(save_path)
# 下载图片
for i, img_tag in enumerate(img_tags):
img_url = img_tag["src"]
response = requests.get(img_url, headers=headers)
with open(os.path.join(save_path, f"pixiv_{i}.jpg"), "wb") as f:
f.write(response.content)
print("图片下载完成!")
```
该爬虫使用requests库发送HTTP请求,使用BeautifulSoup库解析HTML,使用os库创建文件夹,遍历图片链接并下载图片。请注意,该爬虫只是一个简单的示例,并不一定能够爬取所有的pixiv图片。
阅读全文
相关推荐













