first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
module.exports = {
BaseUrl: 'https://www.ixiumei.com/gallery/starphoto/'
}

View File

@@ -0,0 +1,27 @@
// const dddd = require("axios");
const dddd = require("request");
const fs = require("fs");
const cheerio = require('cheerio')
const config = require("./config")
dddd(config.BaseUrl, function(error, response, body) {
// 使用 cheerio 插件将获取到的html转为为虚拟dom
var $ = cheerio.load(body)
$(".mod-img-list li").each(function(i, e) {
if (i <= 7) {
var a = "http:" + $(e).find("img").attr("src")
wirteFile(a, $(this).find("p a").text())
} else {
var b = "http:" + $(e).find("img").attr("data-original")
wirteFile(b, $(this).find("p a").text())
}
})
});
/**
*
*/
function wirteFile(url, name) {
dddd(url).pipe(fs.createWriteStream(`img/${name}.jpg`))
}

View File

@@ -0,0 +1,5 @@
{
"name": "pc",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@@ -0,0 +1,17 @@
{
"name": "pc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"pc": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.21.0",
"cheerio": "^1.0.0-rc.3",
"request": "^2.88.2"
}
}

View File

@@ -0,0 +1,5 @@
1:使用程序(xxxx)访问目标网页 xxxx
html 字符串转化 虚拟dom
2: 使用正则表达式 或 dom操作 从网页的html中提取你要的数据