提交 5bb872a5 编写于 作者: 怪力左手's avatar 怪力左手

update

上级 50a883a9
......@@ -2,13 +2,20 @@ const express = require('express')
const puppeteer = require('puppeteer');
const {Worker,markAsUntransferable} = require('worker_threads');
(async ()=>{
let lottery = new Worker('./lottery.js'),lottery_data
lottery.on('message', o => lottery_data=o)
let lottery_data,stock_data
(async ()=>{
let lottery = new Worker('./lottery.js')
lottery.on('message', o => {
lottery_data=o
console.log(o)
})
lottery.on('error',o => console.log('lottery',o))
let stock = new Worker('./stock.js'),stock_data
stock.on('message', o => stock_data = o)
let stock = new Worker('./stock.js')
stock.on('message', o => {
stock_data = o
console.log(o)
})
stock.on('error', o => console.log('stock',o))
})()
......@@ -21,7 +28,7 @@ app.get('/list',function(req,res){
stock.postMessage(req.params['marked'])
})
app.get('/stock',function(req,res){
res.send(stock_data)
res.send(stock_data.Result.fivedays)
})
app.get('/lottery',function(req,res){
res.send(lottery_data)
......
......@@ -8,7 +8,7 @@ async function start_grab(page){
await page.goto("http://kaijiang.500.com/?0_ala_baidu")
const element = await page.waitForSelector('.kj_tablelist01')
await lottery_new(element)
await lottery_history(element)
//await lottery_history(element)
}catch(e){
console.log(e)
}
......
......@@ -11,6 +11,7 @@
"core-js": "^3.8.3",
"element-plus": "^2.2.29",
"vue": "^3.2.13",
"vue-echarts": "^6.5.4",
"vue-router": "^4.1.6"
},
"devDependencies": {
......
......@@ -18,6 +18,12 @@ export default {
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
width: 100%;
height: 100%;
}
html,body{
width: 100%;
height: 100%;
margin:0;
}
</style>
<template>
<p>hello world</p>
</template>
<script>
export default {
}
</script>
\ No newline at end of file
......@@ -5,17 +5,20 @@ import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import {createRouter,createWebHashHistory} from 'vue-router';
import LoginPage from './components/LoginPage.vue'
import "echarts";
import ECharts from 'vue-echarts'
import HomePage from './components/HomePage.vue'
const router = createRouter({
history: createWebHashHistory(),
routes:[
{ path: '/', component:LoginPage},
{ path: '/', component:HomePage},
]
})
const app = createApp(App)
app.config.globalProperties.$server_url = '/'//'http://localhost:80/'
app.config.productionTip = true
app.component('v-chart',ECharts)
app.use(ElementPlus, {locale: zhCn})
.use(router)
.mount('#app')
.use(router).mount('#app')
......@@ -6,6 +6,10 @@ const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
module.exports = defineConfig({
transpileDependencies: true,
publicPath:".",
devServer: {
proxy: 'http://localhost/',
changeOrigin:true,
},
configureWebpack: {
devtool: 'eval-source-map',
plugins: [
......
const puppeteer = require('puppeteer')
const { parentPort,workerData } = require('worker_threads')
let timeout = 1000,stock_data=['海康威视']
async function start_grab(browser){
async function start_grab(browser,stock_data){
try{
for(i in stock_data){
first = true;
......@@ -12,19 +11,25 @@ async function start_grab(browser){
if(response.request().resourceType()==="xhr"
&& response.status() === 200
&& response.url().includes('getstockquotation') ){
console.log(await response.json())
parentPort.postMessage(await response.json())
}
// if(response.request().url().includes('sug?')){
// console.log(response.request().url())
// if(response.request().resourceType()==="xhr")
// console.log(await response.json())
// }
}catch(e){
console.log(e)
}
})
await page.goto("https://gushitong.baidu.com/",{ waitUntil: ['networkidle0']})
await page.type("#search",stock_data[i])
const element = await page.waitForSelector('.result-list')
element.$x(o=>console.log(o.innerHtml))
//getrelatedblock?stock= 板块
await page.goto('https://gushitong.baidu.com')
await page.type("#search",stock_data[i],{delay:50})
const element = await page.waitForSelector('.list-item-wrap')
const item = await element.waitForSelector('.list-item')
await item.click()
console.log('====='+stock_data[i])
}
}catch(e){
console.log(e)
......@@ -33,13 +38,13 @@ async function start_grab(browser){
async function run(){
const browser = await puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
devtools:true
headless: false,
//ignoreHTTPSErrors: true,
//devtools:true
})
parentPort.on('message', o => stock_data = o)
parentPort.on('message', o => start_grab(browser, o))
parentPort.on('error', o => console.log('stock',o))
parentPort.on('exit',async () => await browser.close())
start_grab(browser)
start_grab(browser, ['中国银行'])
}
run()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册