Run clippy fix

This commit is contained in:
Cameron
2026-01-14 13:17:58 -05:00
parent e9729e9956
commit e2d6cd7258
19 changed files with 123 additions and 158 deletions

View File

@@ -29,24 +29,23 @@ pub fn parse_search_html(path: &str) -> Result<Vec<ParsedSearchRecord>> {
}
// Strategy 2: Look for outer-cell structure (older format)
if records.is_empty() {
if let Ok(outer_selector) = Selector::parse("div.outer-cell") {
if records.is_empty()
&& let Ok(outer_selector) = Selector::parse("div.outer-cell") {
for cell in document.select(&outer_selector) {
if let Some(record) = parse_outer_cell(&cell) {
records.push(record);
}
}
}
}
// Strategy 3: Generic approach - look for links and timestamps
if records.is_empty() {
if let Ok(link_selector) = Selector::parse("a") {
if records.is_empty()
&& let Ok(link_selector) = Selector::parse("a") {
for link in document.select(&link_selector) {
if let Some(href) = link.value().attr("href") {
// Check if it's a search URL
if href.contains("google.com/search?q=") || href.contains("search?q=") {
if let Some(query) = extract_query_from_url(href) {
if (href.contains("google.com/search?q=") || href.contains("search?q="))
&& let Some(query) = extract_query_from_url(href) {
// Try to find nearby timestamp
let timestamp = find_nearby_timestamp(&link);
@@ -56,11 +55,9 @@ pub fn parse_search_html(path: &str) -> Result<Vec<ParsedSearchRecord>> {
search_engine: Some("Google".to_string()),
});
}
}
}
}
}
}
Ok(records)
}
@@ -120,13 +117,12 @@ fn extract_query_from_url(url: &str) -> Option<String> {
fn find_nearby_timestamp(element: &scraper::ElementRef) -> Option<i64> {
// Look for timestamp in parent or sibling elements
if let Some(parent) = element.parent() {
if parent.value().as_element().is_some() {
if let Some(parent) = element.parent()
&& parent.value().as_element().is_some() {
let parent_ref = scraper::ElementRef::wrap(parent)?;
let text = parent_ref.text().collect::<Vec<_>>().join(" ");
return parse_timestamp_from_text(&text);
}
}
None
}
@@ -139,11 +135,9 @@ fn parse_timestamp_from_text(text: &str) -> Option<i64> {
if let Some(iso_match) = text
.split_whitespace()
.find(|s| s.contains('T') && s.contains('-'))
{
if let Ok(dt) = DateTime::parse_from_rfc3339(iso_match) {
&& let Ok(dt) = DateTime::parse_from_rfc3339(iso_match) {
return Some(dt.timestamp());
}
}
// Try common date patterns
let patterns = [
@@ -154,11 +148,10 @@ fn parse_timestamp_from_text(text: &str) -> Option<i64> {
for pattern in patterns {
// Extract potential date string
if let Some(date_part) = extract_date_substring(text) {
if let Ok(dt) = NaiveDateTime::parse_from_str(&date_part, pattern) {
if let Some(date_part) = extract_date_substring(text)
&& let Ok(dt) = NaiveDateTime::parse_from_str(&date_part, pattern) {
return Some(dt.and_utc().timestamp());
}
}
}
None