Skip to content

Commit

Permalink
starting on page parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jordannakamoto committed Aug 21, 2024
1 parent e2c7693 commit 8d26923
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
Binary file modified public/frog/config.seospiderconfig
Binary file not shown.
2 changes: 2 additions & 0 deletions src/app/api/find-onpage/notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. install pip
2. install python library
39 changes: 39 additions & 0 deletions src/app/api/find-onpage/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Load OnPage data into program

import { NextResponse } from "next/server";
import fs from 'fs';
import { parse } from 'csv-parse/sync'; // A more robust CSV parsing
import path from 'path';

export async function POST(request) {
try {
const data = await request.json();
const pages = data.pages;
const dir = data.dir;

// extract urls from pages
for each page in pages
get page url (maybe we use a map)
get page h1
to create a new list of processedpages


// transform pages into filenames
// example: https.10xlivingctc.com > rendered_https_10xlivingctc.com_html

// for everyfilename supply as argument to convert.py
// convert.py will return .md files for each file originating from a page

// for all .md files, open and scan for processedpages.h1
/2/ get the text from the markdown paragraph or line immediately following the h1 position
// append that data to processedpages as page.onpage
// return processed pages



return NextResponse.json({ result }, { status: 200 });
} catch (error) {
console.error('Failed to process files:', error);
return NextResponse.json( { message: "ERROR" } , { status: 500 });
}
}
1 change: 1 addition & 0 deletions src/app/api/load-from-frog-data-fields/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function POST(request) {
const h1FilePath = path.join(directoryPath, dir, 'h1_all.csv');
const h2FilePath = path.join(directoryPath, dir, 'h2_all.csv');
const metaDescriptionFilePath = path.join(directoryPath, dir, 'meta_description_all.csv');
// ! const

// Helper function to read and parse a CSV file
const readAndParseCSV = (filePath) => {
Expand Down
1 change: 1 addition & 0 deletions src/app/api/write-to-workbook/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ async function processOnPageSheet(sheets, data) {
// Add more updateCells requests as needed for other rows
);
if(page.onpageNew){
console.log("highlighting onpage");
requests.push(
{ updateCells: { range: { sheetId, startRowIndex: rowIndex + 5, endRowIndex: rowIndex + 6, startColumnIndex: 0, endColumnIndex: 1 }, rows: [{ values: [{ userEnteredValue: { stringValue: page.onpageNew }, userEnteredFormat: { backgroundColor: HIGHLIGHT_COLOR } }] }], fields: 'userEnteredValue,userEnteredFormat.backgroundColor' } },
)
Expand Down

0 comments on commit 8d26923

Please sign in to comment.