0.2.7 • Published 6 years ago
yu-ncov-scrape-dxy v0.2.7
yu-ncov-scrape-dxy
yu-ncov-scrape-dxy is a library for scrape ncov-2019 data from https://ncov.dxy.cn/ncovh5/view/pneumonia.
从丁香园中获取ncov-2019国家、省份、城市数据
Installation (安装)
To install the stable version:
npm install yu-ncov-scrape-dxyData Struct (数据结构)
export interface BasicRecord {
  suspectedCount: number,
  confirmedCount: number,
  curedCount: number,
  deadCount: number,
  recordAt: Date
}
export interface CountryRecord extends BasicRecord {
  seriousCount?: number,
  suspectedAddCount?: number,
  confirmedAddCount?: number,
  seriousAddCount?: number,
  curedAddCount?: number,
  deadAddCount?: number,
  country: string,
  continents: string,
}
export interface ProvinceRecord extends BasicRecord {
  country: string,
  province: string
}
export interface CityRecord extends BasicRecord {
  country: string,
  province: string,
  city: string,
}
interface Rumor {
 
  title: string
  subTitle: string
  content: string
  recordAt:Date
}
interface News{
 
  title: string
  subTitle?: string
  content: string
  recordAt:Date
  infoSource:string
  province:string
  sourceUrl:string
}
export interface NCOVRecord {
  countries: CountryRecord[],
  provinces: ProvinceRecord[],
  cities: CityRecord[]
   rumors: Rumor[]
  newses: News[]
}scrape to NCOVRecord (获取数据)
import {scrapeToFile} from 'yu-ncov-scrape-dxy'
scrapeToRecord().then((data)=>{
  console.log(data)
})scrape to file (数据写入文件))
import {scrapeToFile} from 'yu-ncov-scrape-dxy'
import {join} from 'path'
scrapeToFile(join(process.cwd(), 'ncov.json').then(()=>{
    console.log(`scrape file to ${process.cwd()}/ncov.json over`)
})License
The MIT License (MIT)