Skip to content

Commit

Permalink
#44 Feed
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzamu committed Jan 25, 2020
1 parent 039a230 commit 9327107
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
5 changes: 5 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ $ meteor --once --settings atc.json
$ meteor --settings drugshortage.json --once


### Import from pei.de
$ meteor --settings pei.json --once



#### Check files
$ cd public/exports

Expand Down
29 changes: 5 additions & 24 deletions server/pei.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ const _ = require("lodash")
const cheerio = require('cheerio');
const puppeteer = require('puppeteer');
const cheerioTableparser = require('cheerio-tableparser')




// const xmltwojs = require('xmltwojs');
import Log from './log.js';
import './util.js'
Expand All @@ -21,9 +17,6 @@ const feed = 'https://www.pei.de/SiteGlobals/Functions/RSSFeed/RSSGenerator_Lief
const fileName = "impfstoffe_deutschland_lieferengpass.json"
var drugsCollection = []
var counter = 0;



/**
*
*/
Expand Down Expand Up @@ -52,21 +45,14 @@ async function scrapper(url) {
});
const page = await browser.newPage();
//

//
await page.goto(feed, {
waitUntil: 'load'
});
var content = await page.content();
// console.log(content)
var $ = await cheerio.load(content, { xmlMode: true });
var items = $('item')

var rows = []




$('item').each((index, item)=>{
var obj = {}
obj.name = $(item).find('title').text()
Expand All @@ -79,10 +65,8 @@ async function scrapper(url) {
console.log(obj)
rows.push(obj)
})



await App.writeFile('/exports/FEED_impfstoffe_deutschland_lieferengpass.json' + fileName, JSON.stringify(rows));
await App.writeFile('/exports/impfstoffe_deutschland_lieferengpass.json', JSON.stringify(rows));
Log('success', 'The file is ready at /exports/impfstoffe_deutschland_lieferengpass.json')
process.exit(0)
return
// //
Expand All @@ -100,7 +84,6 @@ async function scrapper(url) {
*/
async function getTableData(pageContent) {
var $ = await cheerio.load(pageContent);

// getting rows ids
var ids = []
$('tr').each((row)=>{
Expand All @@ -110,11 +93,10 @@ async function getTableData(pageContent) {
ids.push($(row).attr('id'))
}
})




return
/**
* Unfinished Work for Scrapping the HTML Table
*/
console.log('Table count', $('.gsb .c-table table').length)
var tables = []
$('.gsb .c-table table').each(function (index, elm) {
Expand All @@ -141,7 +123,6 @@ async function getTableData(pageContent) {
})
}
}

});
} else {
console.log('Row length EMPTY', $(elm).find('tr').length)
Expand Down

0 comments on commit 9327107

Please sign in to comment.