mirror of
https://github.com/hilmanski/contentswift.git
synced 2026-08-24 02:24:13 -05:00
save scraped result in database
This commit is contained in:
@@ -13,7 +13,10 @@ Surfer SEO, Frase io, ClearScope, NeuronWriter, etc.. (of course they offer more
|
||||
- This is for personal usage, no authentication setup needed in the app itself.
|
||||
- Sign up to [SerpApi](https://serpapi.com) to get FREE Serp search results credit
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
<!--  -->
|
||||
|
||||
## Status
|
||||
Under heavy development. Not for production.
|
||||
|
||||
@@ -11,6 +11,7 @@ class Post(SQLModel, table=True):
|
||||
search_query: dict = Field(sa_column=Column(JSON))
|
||||
search_result: dict = Field(sa_column=Column(JSON))
|
||||
choosen_links: dict = Field(sa_column=Column(JSON))
|
||||
links_scrape_result: dict = Field(sa_column=Column(JSON))
|
||||
createdAt: datetime = Field(default_factory=datetime.utcnow)
|
||||
updatedAt: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
|
||||
+19
-6
@@ -124,8 +124,16 @@ def deletePost(post_id: str):
|
||||
@app.get('/scrape/{post_id}')
|
||||
async def scrape(post_id: str):
|
||||
post = get_post(post_id)
|
||||
links = post.choosen_links
|
||||
|
||||
# Return early if exists
|
||||
if post.links_scrape_result:
|
||||
return {
|
||||
"status": "success",
|
||||
"data": post.links_scrape_result
|
||||
}
|
||||
|
||||
# Scrape links if new
|
||||
links = post.choosen_links
|
||||
lang = post.search_query['hl']
|
||||
|
||||
contentInfo = []
|
||||
@@ -143,13 +151,18 @@ async def scrape(post_id: str):
|
||||
topKeywords = _getTopKeywords(allKeywords)
|
||||
averageWords = sum([content['totalWords'] for content in contentInfo]) / len(contentInfo)
|
||||
|
||||
links_scrape_result = {
|
||||
"contentInfo": contentInfo,
|
||||
"topKeywords": topKeywords,
|
||||
"averageWords": averageWords
|
||||
}
|
||||
update_post(post_id, {
|
||||
"links_scrape_result": links_scrape_result
|
||||
})
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"contentInfo": contentInfo,
|
||||
"topKeywords": topKeywords,
|
||||
"averageWords": averageWords
|
||||
}
|
||||
"data": links_scrape_result
|
||||
}
|
||||
|
||||
# Currently lang get from hl query parameter
|
||||
|
||||
@@ -63,8 +63,8 @@ export default function AddKeyword() {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
<p className="font-bold">Add New Content+</p>
|
||||
<form action="#" className="p-5 border border-black rounded-xl">
|
||||
<p className="font-bold text-xl">Add New Content+</p>
|
||||
|
||||
<div className="my-5">
|
||||
<p className="">keyword you want to rank</p>
|
||||
@@ -121,6 +121,7 @@ export default function AddKeyword() {
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -162,13 +162,21 @@ export default function Sidebar({
|
||||
|
||||
{
|
||||
menu == 'terms' && (
|
||||
<Terms result={result} />
|
||||
<>
|
||||
{
|
||||
loading ? <p>Loading ... (Up to 1 minutes) </p> : <Terms result={result} />
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
menu == 'outline' && (
|
||||
<Outline result={result} />
|
||||
<>
|
||||
{
|
||||
loading ? <p>Loading ... (Up to 1 minutes)</p> : <Outline result={result} />
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user