Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrapper #11

Merged
merged 16 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,16 @@ services:
image: krravindra/algo-frontend:latest
ports:
- 3000:3000
# volumes:
# - ./:/app
# working_dir: /app
# command: sh -c "npm i && npm start"

scrapper:
image: krravindra/scrapper:latest
ports:
- 8000:8000
# volumes:
# - ./:/app
# working_dir: /app/scrapper
# command: sh -c "pip3 install -r requirements.txt && python3 main.py"

parser:
image: krravindra/parser:latest
ports:
- 8001:8001
# volumes:
# - ./:/app
# working_dir: /app/parser
# command: sh -c "pip3 install -r requirements.txt && python3 parser.py"

- 8001:8001

analyzer:
image: krravindra/analyzer:latest
Expand Down
2 changes: 1 addition & 1 deletion parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ async def keyword_api(request: Request):
async def multialgo_api(request: Request):
payload = await request.json()
url = payload['url'].strip('/') if payload['url'].endswith('/') else payload['url']
algo_choices = ["rabin_karp", "naive", "kmp", "suffix_array", "suffix_tree"]
algo_choices = [ "kmp", "suffix_array", "suffix_tree"]
final_response = {"data": []}
wait_iterator = 0
try:
Expand Down
4 changes: 2 additions & 2 deletions recommender/recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ async def keyword_recommendations_api(request: Request):
return existing_algo_data
else:
logger.info("Let's give that scrapper and parser engines, a tad bit more time")
if wait_iterator > 4:
if wait_iterator > 15:
raise HTTPException(status_code=503, detail="Scrapper and Parser Engines are taking too long, please try again later")
wait_iterator += 1
time.sleep(7)
time.sleep(10)
else:
logger.info("Let's give that scrapper and parser engines, a tad bit more time")
if wait_iterator > 4:
Expand Down
1 change: 1 addition & 0 deletions src/api/keyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function keywordList(payload) {
return final_response;
} catch (error) {
console.error("Error fetching scraper text:", error);
window.location.reload();
return [];
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/api/multiAlgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ async function multialgoComparision(payload) {
.then(data => {
console.log('API response:', data);
final_response = data

return data
})
return final_response;
} catch (error) {
console.error("Error fetching scraper text:", error);
window.location.reload();
return [];
}
}
Expand Down
1 change: 1 addition & 0 deletions src/api/recommendation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function RecommendationList(payload) {
return final_response;
} catch (error) {
console.error("Error fetching scraper text:", error);
window.location.reload();
return [];
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/api/scraperText.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
.then(data => {
console.log('API response:', data);
final_response = data
if (data == null || data.length == 0) {
window.location.reload();
}
return data
})
return final_response;
} catch (error) {
alert("Error fetching scraper text:", error);
alert("That's probably not a valid url, by the way we hate querystrings :)", error);
window.location.reload();
return [];
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/components/homePage/algoComparision.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,15 @@ const AlgoComparision = ({ multialgo }) => {
callbacks: {
label: (context) => {
const label = context.dataset.label || '';
// const name = algoData[context.dataIndex].algoName;
// return `${label}: ${name}`;
return `${label}`

return `${label}`
},
},
},
},
};


return <Bar options={options} data={data} style={{ marginRight:'10%',marginLeft:'13%' }} />;
return <Bar options={options} data={data} style={{ marginRight:'10%',marginLeft:'13%', marginTop: "10%" , marginBottom: "10%"}} />;
};

export default AlgoComparision;
70 changes: 41 additions & 29 deletions src/components/homePage/inSight.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,72 @@
import * as React from 'react';
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper, styled } from '@mui/material';
import * as React from "react";
import {
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Paper,
styled,
} from "@mui/material";

const StyledTableCell = styled(TableCell)(({ theme }) => ({
backgroundColor: '#FABB2E',
backgroundColor: "#FABB2E",
color: theme.palette.common.black,
padding: '8px',
fontWeight: 'bold',
marginRight: '3px',
padding: "8px",
fontWeight: "bold",
marginRight: "3px",
}));

const StyledTableRow = styled(TableRow)(({ theme }) => ({
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.action.hover,
padding: '8px',
"&:nth-of-type(odd)": {
backgroundColor: "#F9E7E7",
padding: "10px",
textAlign: "justify",
},
// hide last border
'&:last-child td, &:last-child th': {
"& > *": {
padding: "8px",
},
"&:last-child td, &:last-child th": {
border: 0,
},
}));

const StickyTableHead = styled(TableHead)({
position: 'sticky',
position: "sticky",
top: 0,
zIndex: 1,
backgroundColor: '#FABB2E',
backgroundColor: "#FABB2E",
});

const TableWrapper = styled('div')({
overflowY: 'auto',
maxHeight: '23%',
marginRight:'10%',
marginTop:'5%',
marginLeft: '10%'
})
const TableWrapper = styled("div")({
overflowY: "auto",
maxHeight: "23%",
marginLeft: "2%",
border: "3px solid white",
});

export default function InsightTable({ analyzerData }) {

return (
<TableWrapper>
<TableContainer component={Paper}>
<Table aria-label="customized table">
<StickyTableHead>
<TableRow>
<StyledTableCell align='center'>Insights</StyledTableCell>
<StyledTableCell align="center">
Krwaler's strong suggestions for your web structure
</StyledTableCell>
</TableRow>
</StickyTableHead>
<TableBody>
{analyzerData && analyzerData.pages.map((page, pageIndex) => (
// Create a new row for each warning
page.warnings.map((warning, warningIndex) => (
<StyledTableRow key={`${pageIndex}-${warningIndex}`}>
{analyzerData &&
analyzerData.pages.map((page, pageIndex) =>
page.warnings.map((warning, warningIndex) => (
<StyledTableRow key={`${pageIndex}-${warningIndex}`}>
{warning}&nbsp;
</StyledTableRow>
))
))}
</StyledTableRow>
))
)}
</TableBody>
</Table>
</TableContainer>
Expand Down
Loading