-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4aa255a
commit 8e7dda8
Showing
4 changed files
with
48 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod app_state; | ||
pub mod string_similarity; | ||
pub mod url; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use crate::scraping::scraper::{self, PageData}; | ||
|
||
pub struct ForumURL { | ||
thread_id: String, | ||
ppp: i32, | ||
start: i32, | ||
} | ||
|
||
pub enum URLType { | ||
Thread, | ||
} | ||
|
||
impl ForumURL { | ||
pub fn new(thread_id: String) -> ForumURL { | ||
ForumURL { | ||
thread_id: thread_id, | ||
ppp: 200, | ||
start: 0, | ||
} | ||
} | ||
|
||
pub fn new_from_post(post_id: String) -> ForumURL { | ||
ForumURL::new("thread_url".to_string()) | ||
} | ||
|
||
pub fn url(&self, url_type: URLType) -> String { | ||
match url_type { | ||
URLType::Thread => format!( | ||
"https://forum.mafiascum.com/t/{}/?ppp={}&start={}", | ||
self.thread_id, self.ppp, self.start | ||
), | ||
} | ||
} | ||
|
||
pub async fn scrape(&self) -> Option<PageData> { | ||
scraper::get_page_details(self.url(URLType::Thread)).await | ||
} | ||
} |