Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bicah(url,awal,akhir){
- url = UrlFetchApp.fetch(''+url+'');
- awal = url.getContentText().split(''+awal+'');
- akhir = awal[1].split(''+akhir+'');
- hasil = akhir[0];
- }
- function bicah(i,t,c){hasil=(c=(t=i.split(""+t))[1].split(""+c))[0]}
- sheet_db = (SpreadsheetApp.openById("1FE8AxjzzAYsz1TSSrzm-dSfGe9gZ0e1dFGZuEOe20og")).getSheetByName("Sheet1")
- function myFunction() {
- var startTime = new Date().getTime();
- total_row = sheet_db.getLastRow()+1
- max = total_row+300;
- console.log("TOTAL ROW =" + total_row + " MAX = " + max + "");
- for(hal = total_row; hal <= max; hal=hal+1){
- nomor = hal;
- url = 'https://repositori.kemdikbud.go.id/'+hal+''
- sheet_db.appendRow([new Date(),url]);
- try {
- urlasli = UrlFetchApp.fetch('https://repositori.kemdikbud.go.id/'+hal+'/').getContentText()
- // console.log(urlasli)
- //sheet_db.getRange(sheet_db.getLastRow(),3).setValue('VALID')
- //title
- bicah(urlasli,'<meta name="eprints.title" content="','"')
- title = hasil
- //console.log(hal,"="+title)
- sheet_db.getRange(hal,4).setValue(title)
- //penulis
- bicah(urlasli,'<meta name="DC.creator" content="','"');
- creator = hasil
- //console.log('penulis : '+creator)
- sheet_db.getRange(hal,5).setValue(creator)
- //type
- bicah(urlasli,'<meta name="DC.type" content="','"');
- type = hasil
- //console.log('type : '+type)
- sheet_db.getRange(hal,6).setValue(type)
- //subject
- bicah(urlasli,'<meta name="DC.subject" content="','"');
- subject = hasil
- //console.log('subjek : '+subject)
- sheet_db.getRange(hal,7).setValue(subject)
- //date
- bicah(urlasli,'<meta name="DC.date" content="','"');
- date = hasil
- //console.log('date : '+date)
- sheet_db.getRange(hal,8).setValue(date)
- //language
- bicah(urlasli,'<meta name="DC.language" content="','"');
- language = hasil
- //console.log('language : '+language)
- sheet_db.getRange(hal,9).setValue(language)
- //pages
- bicah(urlasli,'<meta name="eprints.pages" content="','"')
- pages = hasil
- sheet_db.getRange(hal,10).setValue(pages)
- //description
- bicah(urlasli,'<meta name="DC.description" content="','"');
- description = hasil
- //console.log('deskripsi : '+description)
- sheet_db.getRange(hal,11).setValue(description)
- //document_url
- bicah(urlasli,'<meta name="eprints.document_url" content="','"');
- document_url = hasil
- //console.log('document_url : '+document_url)
- sheet_db.getRange(hal,12).setValue(document_url)
- //SAMPUL
- bicah(urlasli,'class="ep_preview"><table><tr><td><img class="ep_preview_image" alt="" src="','"')
- preview = hasil;
- sheet_db.getRange(hal,13).setValue(document_url)
- // dir = DriveApp.getFoldersByName('').next();
- // //console.log('buat file '+hal+'')
- // id_file = dir.createFile(''+hal+'.txt',''+cok+'').getId()
- // //console.log('LOOP = '+hal+' - VALID')
- var response = UrlFetchApp.fetch(document_url);
- var pdf = response.getBlob().setName(hal+".pdf");
- dir = DriveApp.getFoldersByName('REPO PDF NO').next();
- id_file = dir.createFile(pdf).getId()
- sheet_db.getRange(hal,14).setValue(id_file)
- var pdf = response.getBlob().setName(title+".pdf");
- dir = DriveApp.getFoldersByName('REPO PDF TITLE').next();
- id_file = dir.createFile(pdf).getId()
- sheet_db.getRange(hal,15).setValue(id_file)
- //WEB
- var web = UrlFetchApp.fetch(url).getContentText()
- dir = DriveApp.getFoldersByName('REPO WEB').next();
- id_file = dir.createFile(hal+".txt", web).getId()
- sheet_db.getRange(hal,16).setValue(id_file)
- // sheet_db.appendRow([new Date(),url,'VALID',title]);
- // sheet_db.appendRow([new Date(),url,'VALID',title,creator,type,subject,language,description,document_url,id_file]);
- // if(hal==max){
- // var endTime = new Date().getTime();
- // var duration = endTime - startTime;
- // var milliseconds = parseInt((duration%1000)/100)
- // , seconds = parseInt((duration/1000)%60)
- // , minutes = parseInt((duration/(1000*60))%60);
- // lapor_wa("6285217707011","REPO "+total_row+" - "+hal+" - eksekusi: " + minutes + " : " + seconds + " : " + milliseconds + "0 ")
- // }
- sheet_db.getRange(sheet_db.getLastRow(),3).setValue('VALID')
- } catch (error) {
- console.log(error)
- console.log('LOOP = '+hal+' - ERROR')
- sheet_db.getRange(sheet_db.getLastRow(),3).setValue('ERROR')
- }}}
- function createFolder() {
- var folderName = "";
- var folder = DriveApp.createFolder(folderName);
- Logger.log("Folder created with URL: " + folder.getUrl());
- }
- function buat_file(){
- var response = UrlFetchApp.fetch('');
- var pdf = response.getBlob().setName(title+".pdf");
- dir = DriveApp.getFoldersByName('repo').next();
- dir.createFile(pdf);
- }
- function tes_url(){
- cok = UrlFetchApp.fetch('https://repositori.kemdikbud.go.id/1000').getContentText()
- console.log(cok)
- bicah(cok,'<title>','</title>')
- title = hasil
- console.log(title)
- sheet_db.getRange(1,4).setValue(title)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement