feat: initial make-space full-stack release with weighted multi-provider LLM and Dockerfile
This commit is contained in:
commit
37b323c9ac
55 files changed
+17087
No files matched your search
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "providers"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
domain = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
reqwest = { workspace = true }
|
||||
scraper = { workspace = true }
|
||||
regex = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
url = { workspace = true }
|
||||
urlencoding = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { workspace = true }
|
||||
@@ -0,0 +1,224 @@
|
||||
//! Client for the external browser-scraping microservice (Google Maps, Instagram, ...).
|
||||
//!
|
||||
//! The service is not implemented yet. Contract (async job API):
|
||||
//!
|
||||
//! ```text
|
||||
//! POST {BASE}/jobs
|
||||
//! { "source": "google_maps" | "instagram",
|
||||
//! "place": { "name", "address", "lat", "lng" },
|
||||
//! "limit": 50,
|
||||
//! "callback_url": null }
|
||||
//! -> 202 { "job_id": "..." }
|
||||
//!
|
||||
//! GET {BASE}/jobs/{job_id}
|
||||
//! -> { "status": "queued" | "running" | "done" | "failed",
|
||||
//! "items": [ { "image_url", "caption", "source_url", "taken_at" } ],
|
||||
//! "texts": [ { "text", "source_url" } ],
|
||||
//! "error": null }
|
||||
//! ```
|
||||
//!
|
||||
//! When `BROWSER_SCRAPER_URL` is unset, [`MockBrowserScraper`] is used instead.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{PhotoSourceId, Place, RawPhoto, SourceOutput, TextSnippet};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::PhotoSource;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum BrowserSource {
|
||||
GoogleMaps,
|
||||
Instagram,
|
||||
}
|
||||
|
||||
impl BrowserSource {
|
||||
pub fn photo_source_id(self) -> PhotoSourceId {
|
||||
match self {
|
||||
BrowserSource::GoogleMaps => PhotoSourceId::GoogleMaps,
|
||||
BrowserSource::Instagram => PhotoSourceId::Instagram,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct JobRequest<'a> {
|
||||
pub source: BrowserSource,
|
||||
pub place: JobPlace<'a>,
|
||||
pub limit: usize,
|
||||
pub callback_url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct JobPlace<'a> {
|
||||
pub name: &'a str,
|
||||
pub address: &'a str,
|
||||
pub lat: f64,
|
||||
pub lng: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobCreated {
|
||||
pub job_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum JobState {
|
||||
Queued,
|
||||
Running,
|
||||
Done,
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobResult {
|
||||
pub status: JobState,
|
||||
#[serde(default)]
|
||||
pub items: Vec<JobItem>,
|
||||
#[serde(default)]
|
||||
pub texts: Vec<JobText>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobItem {
|
||||
pub image_url: String,
|
||||
#[serde(default)]
|
||||
pub caption: String,
|
||||
#[serde(default)]
|
||||
pub source_url: String,
|
||||
pub taken_at: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobText {
|
||||
pub text: String,
|
||||
#[serde(default)]
|
||||
pub source_url: String,
|
||||
}
|
||||
|
||||
/// HTTP client for the real service.
|
||||
pub struct BrowserScraperClient {
|
||||
client: reqwest::Client,
|
||||
base: String,
|
||||
source: BrowserSource,
|
||||
poll_every: Duration,
|
||||
timeout: Duration,
|
||||
}
|
||||
|
||||
impl BrowserScraperClient {
|
||||
pub fn new(base: impl Into<String>, source: BrowserSource) -> Self {
|
||||
Self {
|
||||
client: crate::http::api_client(),
|
||||
base: base.into().trim_end_matches('/').to_string(),
|
||||
source,
|
||||
poll_every: Duration::from_secs(2),
|
||||
timeout: Duration::from_secs(120),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PhotoSource for BrowserScraperClient {
|
||||
fn id(&self) -> PhotoSourceId {
|
||||
self.source.photo_source_id()
|
||||
}
|
||||
|
||||
async fn collect(&self, place: &Place, limit: usize) -> anyhow::Result<SourceOutput> {
|
||||
let req = JobRequest {
|
||||
source: self.source,
|
||||
place: JobPlace {
|
||||
name: &place.name,
|
||||
address: if place.road_address.is_empty() { &place.address } else { &place.road_address },
|
||||
lat: place.lat,
|
||||
lng: place.lng,
|
||||
},
|
||||
limit,
|
||||
callback_url: None,
|
||||
};
|
||||
let created: JobCreated = self
|
||||
.client
|
||||
.post(format!("{}/jobs", self.base))
|
||||
.json(&req)
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.json()
|
||||
.await?;
|
||||
|
||||
let deadline = tokio::time::Instant::now() + self.timeout;
|
||||
loop {
|
||||
tokio::time::sleep(self.poll_every).await;
|
||||
let r: JobResult = self
|
||||
.client
|
||||
.get(format!("{}/jobs/{}", self.base, created.job_id))
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.json()
|
||||
.await?;
|
||||
match r.status {
|
||||
JobState::Done => return Ok(to_output(self.id(), r)),
|
||||
JobState::Failed => anyhow::bail!("browser scraper failed: {}", r.error.unwrap_or_default()),
|
||||
_ if tokio::time::Instant::now() > deadline => anyhow::bail!("browser scraper timed out"),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn to_output(source: PhotoSourceId, r: JobResult) -> SourceOutput {
|
||||
SourceOutput {
|
||||
photos: r
|
||||
.items
|
||||
.into_iter()
|
||||
.map(|i| RawPhoto {
|
||||
source,
|
||||
image_url: i.image_url,
|
||||
page_url: i.source_url,
|
||||
caption: i.caption,
|
||||
referer: None,
|
||||
})
|
||||
.collect(),
|
||||
texts: r
|
||||
.texts
|
||||
.into_iter()
|
||||
.map(|t| TextSnippet { source, url: t.source_url, text: t.text })
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Stand-in used until the browser service exists. Returns nothing (but succeeds)
|
||||
/// so the pipeline treats the source as "empty" rather than failed.
|
||||
pub struct MockBrowserScraper {
|
||||
source: BrowserSource,
|
||||
}
|
||||
|
||||
impl MockBrowserScraper {
|
||||
pub fn new(source: BrowserSource) -> Self {
|
||||
Self { source }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PhotoSource for MockBrowserScraper {
|
||||
fn id(&self) -> PhotoSourceId {
|
||||
self.source.photo_source_id()
|
||||
}
|
||||
|
||||
async fn collect(&self, place: &Place, _limit: usize) -> anyhow::Result<SourceOutput> {
|
||||
tracing::info!(source = ?self.source, place = %place.name, "browser scraper not configured (mock): returning no results");
|
||||
Ok(SourceOutput::default())
|
||||
}
|
||||
}
|
||||
|
||||
/// Pick the real client or the mock depending on configuration.
|
||||
pub fn browser_source(base_url: Option<&str>, source: BrowserSource) -> Box<dyn PhotoSource> {
|
||||
match base_url.filter(|u| !u.trim().is_empty()) {
|
||||
Some(u) => Box::new(BrowserScraperClient::new(u, source)),
|
||||
None => Box::new(MockBrowserScraper::new(source)),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
pub const DESKTOP_UA: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36";
|
||||
pub const MOBILE_UA: &str = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1";
|
||||
|
||||
/// Shared HTTP client for scraping: browser UA, cookies, gzip, sane timeouts.
|
||||
pub fn scraping_client() -> reqwest::Client {
|
||||
reqwest::Client::builder()
|
||||
.user_agent(DESKTOP_UA)
|
||||
.cookie_store(true)
|
||||
.connect_timeout(Duration::from_secs(10))
|
||||
.timeout(Duration::from_secs(25))
|
||||
.default_headers({
|
||||
let mut h = reqwest::header::HeaderMap::new();
|
||||
h.insert(reqwest::header::ACCEPT_LANGUAGE, "ko-KR,ko;q=0.9,en;q=0.8".parse().unwrap());
|
||||
h
|
||||
})
|
||||
.build()
|
||||
.expect("reqwest client")
|
||||
}
|
||||
|
||||
/// Client for official JSON APIs.
|
||||
pub fn api_client() -> reqwest::Client {
|
||||
reqwest::Client::builder()
|
||||
.connect_timeout(Duration::from_secs(10))
|
||||
.timeout(Duration::from_secs(20))
|
||||
.build()
|
||||
.expect("reqwest client")
|
||||
}
|
||||
|
||||
/// Extract image URLs from arbitrary text (HTML, embedded JSON) whose host matches
|
||||
/// one of `host_patterns` (regex fragments). Handles `\/` and `\u002F` escaping.
|
||||
pub fn extract_image_urls(body: &str, host_patterns: &[&str]) -> Vec<String> {
|
||||
let unescaped = body.replace("\\u002F", "/").replace("\\/", "/").replace("&", "&");
|
||||
let hosts = host_patterns.join("|");
|
||||
let re = Regex::new(&format!(
|
||||
r#"https?://(?:{hosts})[^\s"'<>\\)]*?\.(?:jpe?g|png|webp|JPE?G|PNG|WEBP)(?:\?[^\s"'<>\\)]*)?"#
|
||||
))
|
||||
.expect("valid regex");
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
re.find_iter(&unescaped)
|
||||
.map(|m| m.as_str().to_string())
|
||||
.filter(|u| seen.insert(u.clone()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn extracts_escaped_urls() {
|
||||
let body = r#"{"a":"https:\/\/ldb-phinf.pstatic.net\/2024\/abc.jpg","b":"https:\u002F\u002Fldb-phinf.pstatic.net\u002Fx\u002Fy.JPG?type=w750"}"#;
|
||||
let urls = extract_image_urls(body, &[r"ldb-phinf\.pstatic\.net"]);
|
||||
assert_eq!(urls.len(), 2);
|
||||
assert!(urls[1].ends_with("?type=w750"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
//! Kakao Local REST API (official) with a keyless web-search fallback (`search.map.kakao.com`).
|
||||
//! Docs: https://developers.kakao.com/docs/latest/ko/local/dev-guide
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::PlaceCandidate;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::PlaceSearch;
|
||||
|
||||
const BASE: &str = "https://dapi.kakao.com/v2/local";
|
||||
const WEB_SEARCH: &str = "https://search.map.kakao.com/mapsearch/map.daum";
|
||||
|
||||
pub struct KakaoLocal {
|
||||
client: reqwest::Client,
|
||||
scrape_client: reqwest::Client,
|
||||
key: String,
|
||||
}
|
||||
|
||||
impl KakaoLocal {
|
||||
pub fn new(key: impl Into<String>) -> Self {
|
||||
Self {
|
||||
client: crate::http::api_client(),
|
||||
scrape_client: crate::http::scraping_client(),
|
||||
key: key.into().trim().to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_api_key(&self) -> bool {
|
||||
!self.key.is_empty()
|
||||
}
|
||||
|
||||
async fn get<T: for<'de> Deserialize<'de>>(&self, path: &str, query: &[(&str, String)]) -> anyhow::Result<T> {
|
||||
let resp = self
|
||||
.client
|
||||
.get(format!("{BASE}/{path}"))
|
||||
.header("Authorization", format!("KakaoAK {}", self.key))
|
||||
.query(query)
|
||||
.send()
|
||||
.await?;
|
||||
let status = resp.status();
|
||||
if !status.is_success() {
|
||||
let body = resp.text().await.unwrap_or_default();
|
||||
anyhow::bail!("kakao {path} {status}: {body}");
|
||||
}
|
||||
Ok(resp.json().await?)
|
||||
}
|
||||
|
||||
pub async fn keyword(&self, query: &str) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
let r: KeywordResp = self.get("search/keyword.json", &[("query", query.to_string()), ("size", "15".into())]).await?;
|
||||
Ok(r.documents.into_iter().map(Into::into).collect())
|
||||
}
|
||||
|
||||
/// Places of category (FD6 음식점, CE7 카페) around a coordinate.
|
||||
pub async fn category_near(&self, code: &str, lat: f64, lng: f64, radius_m: u32) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
let r: KeywordResp = self
|
||||
.get(
|
||||
"search/category.json",
|
||||
&[
|
||||
("category_group_code", code.to_string()),
|
||||
("x", lng.to_string()),
|
||||
("y", lat.to_string()),
|
||||
("radius", radius_m.to_string()),
|
||||
("sort", "distance".into()),
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
Ok(r.documents.into_iter().map(Into::into).collect())
|
||||
}
|
||||
|
||||
/// Address → coordinates (first match).
|
||||
pub async fn address(&self, query: &str) -> anyhow::Result<Option<(f64, f64, String)>> {
|
||||
let r: AddressResp = self.get("search/address.json", &[("query", query.to_string())]).await?;
|
||||
Ok(r.documents.into_iter().next().and_then(|d| {
|
||||
Some((d.y.parse().ok()?, d.x.parse().ok()?, d.address_name))
|
||||
}))
|
||||
}
|
||||
|
||||
/// Keyless fallback via Kakao Map's web JSONP endpoint (`search.map.kakao.com/mapsearch/map.daum`).
|
||||
pub async fn web_search(&self, query: &str) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
let text = self
|
||||
.scrape_client
|
||||
.get(WEB_SEARCH)
|
||||
.header(reqwest::header::REFERER, "https://map.kakao.com/")
|
||||
.query(&[("callback", "j"), ("q", query), ("msFlag", "A"), ("sort", "0")])
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.text()
|
||||
.await?;
|
||||
parse_web_search_jsonp(&text)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_web_search_jsonp(text: &str) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
let start = text.find('{').ok_or_else(|| anyhow::anyhow!("kakao web search: missing JSON object"))?;
|
||||
let end = text.rfind('}').ok_or_else(|| anyhow::anyhow!("kakao web search: missing closing brace"))?;
|
||||
let r: WebSearchResp = serde_json::from_str(&text[start..=end])?;
|
||||
Ok(r.place
|
||||
.into_iter()
|
||||
.filter(|p| !p.confirmid.is_empty() && p.lat != 0.0 && p.lon != 0.0)
|
||||
.map(|p| PlaceCandidate {
|
||||
provider: "kakao".into(),
|
||||
place_url: format!("https://place.map.kakao.com/{}", p.confirmid),
|
||||
provider_id: p.confirmid,
|
||||
name: p.name,
|
||||
category: p.last_cate_name,
|
||||
address: p.address,
|
||||
road_address: p.new_address,
|
||||
phone: p.tel,
|
||||
lat: p.lat,
|
||||
lng: p.lon,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PlaceSearch for KakaoLocal {
|
||||
fn name(&self) -> &'static str {
|
||||
"kakao"
|
||||
}
|
||||
|
||||
/// Uses official REST API when `KAKAO_REST_API_KEY` is set; otherwise falls back
|
||||
/// to Kakao Map's web search so development works without an API key.
|
||||
async fn search(&self, query: &str) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
if !self.has_api_key() {
|
||||
return self.web_search(query).await;
|
||||
}
|
||||
match self.keyword(query).await {
|
||||
Ok(mut out) => {
|
||||
if out.is_empty() || looks_like_address(query) {
|
||||
if let Some((lat, lng, _)) = self.address(query).await.ok().flatten() {
|
||||
for code in ["FD6", "CE7"] {
|
||||
for c in self.category_near(code, lat, lng, 40).await.unwrap_or_default() {
|
||||
if !out.iter().any(|o| o.provider_id == c.provider_id) {
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!("kakao REST search failed ({e}), falling back to web search");
|
||||
self.web_search(query).await
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn looks_like_address(q: &str) -> bool {
|
||||
let re = regex::Regex::new(r"(로|길|동|읍|면|리)\s*\d+(-\d+)?").unwrap();
|
||||
re.is_match(q)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct KeywordResp {
|
||||
documents: Vec<KakaoPlaceDoc>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct KakaoPlaceDoc {
|
||||
id: String,
|
||||
place_name: String,
|
||||
#[serde(default)]
|
||||
category_name: String,
|
||||
#[serde(default)]
|
||||
phone: String,
|
||||
#[serde(default)]
|
||||
address_name: String,
|
||||
#[serde(default)]
|
||||
road_address_name: String,
|
||||
x: String,
|
||||
y: String,
|
||||
#[serde(default)]
|
||||
place_url: String,
|
||||
}
|
||||
|
||||
impl From<KakaoPlaceDoc> for PlaceCandidate {
|
||||
fn from(d: KakaoPlaceDoc) -> Self {
|
||||
PlaceCandidate {
|
||||
provider: "kakao".into(),
|
||||
provider_id: d.id,
|
||||
name: d.place_name,
|
||||
category: d.category_name.rsplit(" > ").next().unwrap_or_default().to_string(),
|
||||
address: d.address_name,
|
||||
road_address: d.road_address_name,
|
||||
phone: d.phone,
|
||||
lat: d.y.parse().unwrap_or_default(),
|
||||
lng: d.x.parse().unwrap_or_default(),
|
||||
place_url: d.place_url,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct AddressResp {
|
||||
documents: Vec<AddressDoc>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct AddressDoc {
|
||||
address_name: String,
|
||||
x: String,
|
||||
y: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct WebSearchResp {
|
||||
#[serde(default)]
|
||||
place: Vec<WebPlaceDoc>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct WebPlaceDoc {
|
||||
#[serde(default)]
|
||||
confirmid: String,
|
||||
#[serde(default)]
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
last_cate_name: String,
|
||||
#[serde(default)]
|
||||
address: String,
|
||||
#[serde(default)]
|
||||
new_address: String,
|
||||
#[serde(default)]
|
||||
tel: String,
|
||||
#[serde(default)]
|
||||
lat: f64,
|
||||
#[serde(default)]
|
||||
lon: f64,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn address_detection() {
|
||||
assert!(looks_like_address("서울 성동구 성수이로 78"));
|
||||
assert!(looks_like_address("연무장길 5-1"));
|
||||
assert!(!looks_like_address("대림창고"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_jsonp() {
|
||||
let raw = r#"/**/j({"place":[{"confirmid":"1128989913","name":"대림창고","last_cate_name":"갤러리카페","address":"서울 성동구 성수동2가 322-32 1층","new_address":"서울 성동구 성수이로 78","tel":"0507-1390-9669","lat":37.5417,"lon":127.0562}]});"#;
|
||||
let list = parse_web_search_jsonp(raw).unwrap();
|
||||
assert_eq!(list.len(), 1);
|
||||
assert_eq!(list[0].provider_id, "1128989913");
|
||||
assert_eq!(list[0].name, "대림창고");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
//! Kakao Map place panel + photos (unofficial, verified 2026-11-04).
|
||||
//!
|
||||
//! Endpoint: `https://place-api.map.kakao.com/places/panel3/{kakao_id}`
|
||||
//! Required headers: `pf: web`, `Referer: https://place.map.kakao.com/{kakao_id}`.
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{PhotoSourceId, Place, RawPhoto, SourceOutput, TextSnippet};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::{http, PhotoSource};
|
||||
|
||||
pub struct KakaoPlacePhotos {
|
||||
client: reqwest::Client,
|
||||
}
|
||||
|
||||
impl Default for KakaoPlacePhotos {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl KakaoPlacePhotos {
|
||||
pub fn new() -> Self {
|
||||
Self { client: http::scraping_client() }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PhotoSource for KakaoPlacePhotos {
|
||||
fn id(&self) -> PhotoSourceId {
|
||||
PhotoSourceId::KakaoPlace
|
||||
}
|
||||
|
||||
async fn collect(&self, place: &Place, limit: usize) -> anyhow::Result<SourceOutput> {
|
||||
let Some(id) = place.kakao_id.as_deref() else {
|
||||
anyhow::bail!("kakao place id missing");
|
||||
};
|
||||
let url = format!("https://place-api.map.kakao.com/places/panel3/{id}");
|
||||
let referer = format!("https://place.map.kakao.com/{id}");
|
||||
let text = self
|
||||
.client
|
||||
.get(&url)
|
||||
.header("pf", "web")
|
||||
.header(reqwest::header::REFERER, &referer)
|
||||
.header(reqwest::header::ACCEPT, "application/json")
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.text()
|
||||
.await?;
|
||||
parse_panel3_json(&text, &referer, limit)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_panel3_json(raw: &str, page_url: &str, limit: usize) -> anyhow::Result<SourceOutput> {
|
||||
let v: Value = serde_json::from_str(raw)?;
|
||||
let mut seen = HashSet::new();
|
||||
let mut photos = Vec::new();
|
||||
let mut text_parts = Vec::new();
|
||||
|
||||
// Address detail often contains explicit floor info, e.g. "서울 성동구 성수이로 78 1층".
|
||||
if let Some(disp) = v.pointer("/summary/address/disp").and_then(Value::as_str) {
|
||||
text_parts.push(format!("주소: {disp}"));
|
||||
}
|
||||
if let Some(detail) = v.pointer("/summary/address/address_detail_part").and_then(Value::as_str) {
|
||||
if !detail.is_empty() {
|
||||
text_parts.push(format!("층/호수 정보: {detail}"));
|
||||
}
|
||||
}
|
||||
if let Some(tags) = v.pointer("/place_add_info/tags").and_then(Value::as_array) {
|
||||
let t: Vec<&str> = tags.iter().filter_map(Value::as_str).collect();
|
||||
if !t.is_empty() {
|
||||
text_parts.push(format!("태그: {}", t.join(", ")));
|
||||
}
|
||||
}
|
||||
if let Some(ai_summary) = v.pointer("/ai_mate/bottom_sheet/summary").and_then(Value::as_str) {
|
||||
text_parts.push(ai_summary.to_string());
|
||||
}
|
||||
if let Some(infos) = v.pointer("/place_add_info/full_detail_infos").and_then(Value::as_array) {
|
||||
for info in infos {
|
||||
let title = info.get("title").and_then(Value::as_str).unwrap_or_default();
|
||||
let items: Vec<&str> = info
|
||||
.get("items")
|
||||
.and_then(Value::as_array)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|i| i.pointer("/icon/text").and_then(Value::as_str))
|
||||
.collect();
|
||||
if !items.is_empty() {
|
||||
text_parts.push(format!("{title}: {}", items.join(", ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Structured photo list
|
||||
if let Some(arr) = v.pointer("/photos/photos").and_then(Value::as_array) {
|
||||
for item in arr {
|
||||
if photos.len() >= limit {
|
||||
break;
|
||||
}
|
||||
if let Some(u) = item.get("url").and_then(Value::as_str) {
|
||||
let clean = unwrap_kakao_thumb(u);
|
||||
if seen.insert(clean.clone()) {
|
||||
let caption = item.get("title").and_then(Value::as_str).unwrap_or_default().to_string();
|
||||
photos.push(RawPhoto {
|
||||
source: PhotoSourceId::KakaoPlace,
|
||||
image_url: clean,
|
||||
page_url: page_url.to_string(),
|
||||
caption,
|
||||
referer: Some("https://place.map.kakao.com/".into()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Review texts + review photos
|
||||
for review_path in ["/kakaomap_review/reviews", "/blog_review/reviews"] {
|
||||
if let Some(reviews) = v.pointer(review_path).and_then(Value::as_array) {
|
||||
for r in reviews {
|
||||
let contents = r
|
||||
.get("contents")
|
||||
.or_else(|| r.get("Summary"))
|
||||
.or_else(|| r.get("title"))
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default();
|
||||
if contents.chars().count() >= 6 {
|
||||
text_parts.push(contents.to_string());
|
||||
}
|
||||
if let Some(p_arr) = r.get("photos").or_else(|| r.get("photo_list")).and_then(Value::as_array) {
|
||||
for p in p_arr {
|
||||
if photos.len() >= limit {
|
||||
break;
|
||||
}
|
||||
if let Some(u) = p.get("url").or_else(|| p.get("orgurl")).and_then(Value::as_str) {
|
||||
let clean = unwrap_kakao_thumb(u);
|
||||
if seen.insert(clean.clone()) {
|
||||
photos.push(RawPhoto {
|
||||
source: PhotoSourceId::KakaoPlace,
|
||||
image_url: clean,
|
||||
page_url: page_url.to_string(),
|
||||
caption: contents.chars().take(180).collect(),
|
||||
referer: Some("https://place.map.kakao.com/".into()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut texts = Vec::new();
|
||||
if !text_parts.is_empty() {
|
||||
let joined: String = text_parts.join("\n").chars().take(3000).collect();
|
||||
texts.push(TextSnippet {
|
||||
source: PhotoSourceId::KakaoPlace,
|
||||
url: page_url.to_string(),
|
||||
text: joined,
|
||||
});
|
||||
}
|
||||
Ok(SourceOutput { photos, texts })
|
||||
}
|
||||
|
||||
/// Unwrap Kakao's thumbnail proxy (`?fname=https%3A%2F%2F...`) and upgrade `http://` to `https://`.
|
||||
pub fn unwrap_kakao_thumb(u: &str) -> String {
|
||||
if let Some(idx) = u.find("fname=") {
|
||||
let encoded = &u[idx + 6..];
|
||||
let end = encoded.find('&').unwrap_or(encoded.len());
|
||||
if let Ok(decoded) = urlencoding::decode(&encoded[..end]) {
|
||||
if decoded.starts_with("http") {
|
||||
return decoded.into_owned().replace("http://", "https://");
|
||||
}
|
||||
}
|
||||
}
|
||||
u.replace("http://", "https://")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn unwraps_fname_proxy() {
|
||||
let u = "https://img1.kakaocdn.net/cthumb/local/R0x420/?fname=http%3A%2F%2Ft1.daumcdn.net%2Flocal%2Fabc.jpg";
|
||||
assert_eq!(unwrap_kakao_thumb(u), "https://t1.daumcdn.net/local/abc.jpg");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_panel_sample() {
|
||||
let sample = r#"{
|
||||
"summary":{"address":{"disp":"서울 성동구 성수이로 78 1층","address_detail_part":"1층"}},
|
||||
"place_add_info":{"tags":["갤러리카페","루프탑있는"]},
|
||||
"photos":{"photos":[{"url":"http://t1.kakaocdn.net/local/kakaomapPhoto/review/abc?original","title":"실내"}]}
|
||||
}"#;
|
||||
let out = parse_panel3_json(sample, "https://place.map.kakao.com/1128989913", 10).unwrap();
|
||||
assert_eq!(out.photos.len(), 1);
|
||||
assert!(out.photos[0].image_url.starts_with("https://"));
|
||||
assert!(out.texts[0].text.contains("루프탑있는"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//! External data providers: place search, geocoding and photo/text sources.
|
||||
//!
|
||||
//! * Official APIs: [`kakao_local`], [`ncp_geocode`]
|
||||
//! * In-process scrapers: [`naver_map`], [`naver_place`], [`naver_blog`], [`kakao_place`]
|
||||
//! * Delegated to the external browser scraping service: [`browser`] (Google Maps, Instagram)
|
||||
|
||||
pub mod browser;
|
||||
pub mod http;
|
||||
pub mod kakao_local;
|
||||
pub mod kakao_place;
|
||||
pub mod naver_blog;
|
||||
pub mod naver_map;
|
||||
pub mod naver_place;
|
||||
pub mod ncp_geocode;
|
||||
pub mod text;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{PhotoSourceId, Place, PlaceCandidate, SourceOutput};
|
||||
|
||||
/// Free-text place search (상호명 / 주소 → candidates).
|
||||
#[async_trait]
|
||||
pub trait PlaceSearch: Send + Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
async fn search(&self, query: &str) -> anyhow::Result<Vec<PlaceCandidate>>;
|
||||
}
|
||||
|
||||
/// A source of photos and text evidence for a resolved place.
|
||||
#[async_trait]
|
||||
pub trait PhotoSource: Send + Sync {
|
||||
fn id(&self) -> PhotoSourceId;
|
||||
async fn collect(&self, place: &Place, limit: usize) -> anyhow::Result<SourceOutput>;
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
//! Naver Blog posts about the place: inline images + body text (unofficial, verified 2026-11-04).
|
||||
//!
|
||||
//! 1. Search `https://search.naver.com/search.naver?ssc=tab.blog.all&query=...` for `blog.naver.com/{blogId}/{logNo}` links.
|
||||
//! 2. Fetch each post via `https://blog.naver.com/PostView.naver?blogId=...&logNo=...` (bypasses outer iframe).
|
||||
//! 3. Parse SmartEditor (`.se-main-container`) paragraphs and `postfiles.pstatic.net` images, pairing each image
|
||||
//! with nearby paragraph text as its caption.
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{PhotoSourceId, Place, RawPhoto, SourceOutput, TextSnippet};
|
||||
use futures::stream::{self, StreamExt};
|
||||
use regex::Regex;
|
||||
use scraper::{Html, Selector};
|
||||
|
||||
use crate::{http, PhotoSource};
|
||||
|
||||
const SEARCH_URL: &str = "https://search.naver.com/search.naver";
|
||||
const POST_VIEW_URL: &str = "https://blog.naver.com/PostView.naver";
|
||||
|
||||
pub struct NaverBlog {
|
||||
client: reqwest::Client,
|
||||
max_posts: usize,
|
||||
}
|
||||
|
||||
impl Default for NaverBlog {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl NaverBlog {
|
||||
pub fn new() -> Self {
|
||||
Self { client: http::scraping_client(), max_posts: 8 }
|
||||
}
|
||||
|
||||
async fn search_post_ids(&self, query: &str) -> anyhow::Result<Vec<(String, String)>> {
|
||||
let html = self
|
||||
.client
|
||||
.get(SEARCH_URL)
|
||||
.header(reqwest::header::REFERER, "https://search.naver.com/")
|
||||
.query(&[("ssc", "tab.blog.all"), ("query", query)])
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.text()
|
||||
.await?;
|
||||
Ok(extract_blog_post_ids(&html))
|
||||
}
|
||||
|
||||
async fn fetch_post(&self, blog_id: &str, log_no: &str) -> anyhow::Result<SourceOutput> {
|
||||
let page_url = format!("https://blog.naver.com/{blog_id}/{log_no}");
|
||||
let html = self
|
||||
.client
|
||||
.get(POST_VIEW_URL)
|
||||
.header(reqwest::header::REFERER, "https://blog.naver.com/")
|
||||
.query(&[("blogId", blog_id), ("logNo", log_no)])
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.text()
|
||||
.await?;
|
||||
Ok(parse_blog_post_html(&html, &page_url))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PhotoSource for NaverBlog {
|
||||
fn id(&self) -> PhotoSourceId {
|
||||
PhotoSourceId::NaverBlog
|
||||
}
|
||||
|
||||
async fn collect(&self, place: &Place, limit: usize) -> anyhow::Result<SourceOutput> {
|
||||
let region = place.region_hint();
|
||||
let q1 = format!("{} {} 내부 좌석", region, place.name);
|
||||
let q2 = format!("{} {}", region, place.name);
|
||||
|
||||
let mut post_ids = self.search_post_ids(q1.trim()).await.unwrap_or_default();
|
||||
if post_ids.len() < self.max_posts {
|
||||
for id in self.search_post_ids(q2.trim()).await.unwrap_or_default() {
|
||||
if !post_ids.contains(&id) {
|
||||
post_ids.push(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
post_ids.truncate(self.max_posts);
|
||||
|
||||
let results: Vec<SourceOutput> = stream::iter(post_ids)
|
||||
.map(|(b, l)| async move { self.fetch_post(&b, &l).await.ok() })
|
||||
.buffer_unordered(4)
|
||||
.filter_map(|x| async move { x })
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
let mut seen = HashSet::new();
|
||||
let mut photos = Vec::new();
|
||||
let mut texts = Vec::new();
|
||||
for r in results {
|
||||
texts.extend(r.texts);
|
||||
for p in r.photos {
|
||||
if photos.len() >= limit {
|
||||
break;
|
||||
}
|
||||
if seen.insert(p.image_url.clone()) {
|
||||
photos.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(SourceOutput { photos, texts })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_blog_post_ids(html: &str) -> Vec<(String, String)> {
|
||||
let re = Regex::new(r"https?://(?:m\.)?blog\.naver\.com/([a-zA-Z0-9_\-]+)/(\d{10,15})").unwrap();
|
||||
let mut seen = HashSet::new();
|
||||
let mut out = Vec::new();
|
||||
for c in re.captures_iter(html) {
|
||||
let pair = (c[1].to_string(), c[2].to_string());
|
||||
if seen.insert(pair.clone()) {
|
||||
out.push(pair);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
pub fn parse_blog_post_html(html: &str, page_url: &str) -> SourceOutput {
|
||||
let doc = Html::parse_document(html);
|
||||
let container_sel = Selector::parse(".se-main-container, #postViewArea").unwrap();
|
||||
let p_sel = Selector::parse(".se-text-paragraph, p").unwrap();
|
||||
let img_sel = Selector::parse("img").unwrap();
|
||||
|
||||
let mut paragraphs = Vec::new();
|
||||
for container in doc.select(&container_sel) {
|
||||
for p in container.select(&p_sel) {
|
||||
let t = p.text().collect::<Vec<_>>().join(" ");
|
||||
let clean = t.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
if clean.chars().count() >= 4 {
|
||||
paragraphs.push(clean);
|
||||
}
|
||||
}
|
||||
}
|
||||
if paragraphs.is_empty() {
|
||||
for p in doc.select(&p_sel) {
|
||||
let clean = p.text().collect::<Vec<_>>().join(" ").split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
if clean.chars().count() >= 4 {
|
||||
paragraphs.push(clean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let full_text: String = paragraphs.join("\n").chars().take(3000).collect();
|
||||
let mut texts = Vec::new();
|
||||
if !full_text.is_empty() {
|
||||
texts.push(TextSnippet {
|
||||
source: PhotoSourceId::NaverBlog,
|
||||
url: page_url.to_string(),
|
||||
text: full_text.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
let mut seen = HashSet::new();
|
||||
let mut photos = Vec::new();
|
||||
for img in doc.select(&img_sel) {
|
||||
let v = img.value();
|
||||
let src = v
|
||||
.attr("data-lazy-src")
|
||||
.or_else(|| v.attr("data-src"))
|
||||
.or_else(|| v.attr("src"))
|
||||
.unwrap_or_default();
|
||||
if let Some(url) = normalize_blog_image_url(src) {
|
||||
if seen.insert(url.clone()) {
|
||||
photos.push(RawPhoto {
|
||||
source: PhotoSourceId::NaverBlog,
|
||||
image_url: url,
|
||||
page_url: page_url.to_string(),
|
||||
caption: String::new(),
|
||||
referer: Some("https://blog.naver.com/".into()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fallback regex scan if DOM attributes differed
|
||||
if photos.is_empty() {
|
||||
for u in http::extract_image_urls(html, &[r"postfiles\.pstatic\.net", r"blogfiles\.pstatic\.net"]) {
|
||||
if let Some(url) = normalize_blog_image_url(&u) {
|
||||
if seen.insert(url.clone()) {
|
||||
photos.push(RawPhoto {
|
||||
source: PhotoSourceId::NaverBlog,
|
||||
image_url: url,
|
||||
page_url: page_url.to_string(),
|
||||
caption: String::new(),
|
||||
referer: Some("https://blog.naver.com/".into()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spread paragraph context across photos proportionally
|
||||
if !paragraphs.is_empty() && !photos.is_empty() {
|
||||
let n_p = paragraphs.len();
|
||||
let n_img = photos.len();
|
||||
for (i, photo) in photos.iter_mut().enumerate() {
|
||||
let center = (i * n_p) / n_img;
|
||||
let start = center.saturating_sub(1);
|
||||
let end = (center + 2).min(n_p);
|
||||
photo.caption = paragraphs[start..end].join(" ").chars().take(220).collect();
|
||||
}
|
||||
}
|
||||
|
||||
SourceOutput { photos, texts }
|
||||
}
|
||||
|
||||
fn normalize_blog_image_url(raw: &str) -> Option<String> {
|
||||
let u = raw.replace("&", "&");
|
||||
if !(u.contains("postfiles.pstatic.net") || u.contains("blogfiles.pstatic.net")) {
|
||||
return None;
|
||||
}
|
||||
let lower = u.to_ascii_lowercase();
|
||||
if lower.contains("sticker") || lower.contains("emoticon") || lower.contains("profile") || lower.contains(".gif") {
|
||||
return None;
|
||||
}
|
||||
let base = u.split('?').next().unwrap_or(&u);
|
||||
Some(format!("{base}?type=w966"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parses_blog_html() {
|
||||
let html = r#"<div class="se-main-container">
|
||||
<p class="se-text-paragraph">1층에서 주문하고 2층으로 올라갔어요</p>
|
||||
<img data-lazy-src="https://postfiles.pstatic.net/2026/img1.JPEG?type=w80_blur"/>
|
||||
<p class="se-text-paragraph">창가 바 좌석이 6자리 정도 있어요</p>
|
||||
</div>"#;
|
||||
let out = parse_blog_post_html(html, "https://blog.naver.com/a/123456789012");
|
||||
assert_eq!(out.photos.len(), 1);
|
||||
assert_eq!(out.photos[0].image_url, "https://postfiles.pstatic.net/2026/img1.JPEG?type=w966");
|
||||
assert!(out.photos[0].caption.contains("2층"));
|
||||
assert_eq!(out.texts.len(), 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
//! Naver Map web search (unofficial, verified 2026-11-04).
|
||||
//!
|
||||
//! Primary endpoint: `https://map.naver.com/p/api/search/instant-search?query=...&coords=lat,lng`
|
||||
//! Fallback endpoint: `https://m.place.naver.com/place/list?query=...&x=lng&y=lat` (parses `window.__APOLLO_STATE__`).
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{Place, PlaceCandidate};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::{http, text, PlaceSearch};
|
||||
|
||||
const INSTANT_URL: &str = "https://map.naver.com/p/api/search/instant-search";
|
||||
const MPLACE_LIST_URL: &str = "https://m.place.naver.com/place/list";
|
||||
|
||||
pub struct NaverMapSearch {
|
||||
client: reqwest::Client,
|
||||
}
|
||||
|
||||
impl Default for NaverMapSearch {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl NaverMapSearch {
|
||||
pub fn new() -> Self {
|
||||
Self { client: http::scraping_client() }
|
||||
}
|
||||
|
||||
/// Search places on Naver Map, optionally biased around `(lat, lng)`.
|
||||
pub async fn search_near(&self, query: &str, near: Option<(f64, f64)>) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
let mut out = self.instant_search(query, near).await.unwrap_or_default();
|
||||
if out.is_empty() {
|
||||
if let Ok(fallback) = self.mobile_list_search(query, near).await {
|
||||
out = fallback;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
async fn instant_search(&self, query: &str, near: Option<(f64, f64)>) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
let (lat, lng) = near.unwrap_or((37.5665, 126.9780));
|
||||
let coords = format!("{lat},{lng}");
|
||||
let resp = self
|
||||
.client
|
||||
.get(INSTANT_URL)
|
||||
.header(reqwest::header::REFERER, "https://map.naver.com/")
|
||||
.query(&[("query", query), ("coords", &coords)])
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?;
|
||||
let body: InstantResp = resp.json().await?;
|
||||
Ok(parse_instant(body))
|
||||
}
|
||||
|
||||
async fn mobile_list_search(&self, query: &str, near: Option<(f64, f64)>) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
let (lat, lng) = near.unwrap_or((37.5665, 126.9780));
|
||||
let html = self
|
||||
.client
|
||||
.get(MPLACE_LIST_URL)
|
||||
.header(reqwest::header::USER_AGENT, http::MOBILE_UA)
|
||||
.query(&[("query", query), ("x", &lng.to_string()), ("y", &lat.to_string())])
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.text()
|
||||
.await?;
|
||||
Ok(parse_apollo_place_list(&html))
|
||||
}
|
||||
|
||||
/// Find the Naver place id matching `place` (name similarity + coordinate distance).
|
||||
pub async fn resolve_place_id(&self, place: &Place) -> anyhow::Result<Option<String>> {
|
||||
let queries = [
|
||||
format!("{} {}", place.name, place.region_hint()),
|
||||
place.name.clone(),
|
||||
];
|
||||
for q in queries {
|
||||
let candidates = self.search_near(q.trim(), Some((place.lat, place.lng))).await.unwrap_or_default();
|
||||
if let Some(id) = pick_best_match(place, &candidates) {
|
||||
tracing::debug!(place = %place.name, naver_id = %id, "resolved naver place id");
|
||||
return Ok(Some(id));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pick_best_match(place: &Place, candidates: &[PlaceCandidate]) -> Option<String> {
|
||||
candidates
|
||||
.iter()
|
||||
.filter_map(|c| {
|
||||
let sim = text::name_similarity(&place.name, &c.name);
|
||||
let dist = text::haversine_m(place.lat, place.lng, c.lat, c.lng);
|
||||
// Accept either strong name similarity within 200m, or very close (<50m) with moderate name match.
|
||||
if (sim >= 0.55 && dist <= 200.0) || (sim >= 0.35 && dist <= 50.0) {
|
||||
let score = sim * 100.0 - (dist as f32) * 0.2;
|
||||
Some((score, c.provider_id.clone()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.max_by(|a, b| a.0.total_cmp(&b.0))
|
||||
.map(|(_, id)| id)
|
||||
}
|
||||
|
||||
fn parse_instant(body: InstantResp) -> Vec<PlaceCandidate> {
|
||||
body.place
|
||||
.into_iter()
|
||||
.filter_map(|p| {
|
||||
let lat: f64 = p.y.parse().ok()?;
|
||||
let lng: f64 = p.x.parse().ok()?;
|
||||
Some(PlaceCandidate {
|
||||
provider: "naver".into(),
|
||||
place_url: format!("https://m.place.naver.com/place/{}/home", p.id),
|
||||
provider_id: p.id,
|
||||
name: p.title,
|
||||
category: p.ctg,
|
||||
address: p.jibun_address,
|
||||
road_address: p.road_address,
|
||||
phone: String::new(),
|
||||
lat,
|
||||
lng,
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn parse_apollo_place_list(html: &str) -> Vec<PlaceCandidate> {
|
||||
let Some(state) = extract_apollo_state(html) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let Some(obj) = state.as_object() else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut out = Vec::new();
|
||||
for (k, v) in obj {
|
||||
if !k.starts_with("PlaceListBusinessesItem:") && !k.starts_with("PlaceSummary:") {
|
||||
continue;
|
||||
}
|
||||
let Some(id) = v.get("id").and_then(Value::as_str) else { continue };
|
||||
let Some(name) = v.get("name").and_then(Value::as_str) else { continue };
|
||||
let lat: f64 = v.get("y").and_then(Value::as_str).and_then(|s| s.parse().ok()).unwrap_or_default();
|
||||
let lng: f64 = v.get("x").and_then(Value::as_str).and_then(|s| s.parse().ok()).unwrap_or_default();
|
||||
if lat == 0.0 || lng == 0.0 {
|
||||
continue;
|
||||
}
|
||||
let category = v.get("category").and_then(Value::as_str).unwrap_or_default().to_string();
|
||||
let address = v
|
||||
.get("fullAddress")
|
||||
.or_else(|| v.get("address"))
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
let road_address = v.get("roadAddress").and_then(Value::as_str).unwrap_or_default().to_string();
|
||||
let phone = v
|
||||
.get("phone")
|
||||
.or_else(|| v.get("virtualPhone"))
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
out.push(PlaceCandidate {
|
||||
provider: "naver".into(),
|
||||
provider_id: id.to_string(),
|
||||
name: name.to_string(),
|
||||
category,
|
||||
address,
|
||||
road_address,
|
||||
phone,
|
||||
lat,
|
||||
lng,
|
||||
place_url: format!("https://m.place.naver.com/place/{id}/home"),
|
||||
});
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Extract the first JSON object assigned to `__APOLLO_STATE__`.
|
||||
pub fn extract_apollo_state(html: &str) -> Option<Value> {
|
||||
let marker = "__APOLLO_STATE__";
|
||||
let idx = html.find(marker)?;
|
||||
let rest = &html[idx + marker.len()..];
|
||||
let brace = rest.find('{')?;
|
||||
let mut de = serde_json::Deserializer::from_str(&rest[brace..]).into_iter::<Value>();
|
||||
de.next()?.ok()
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PlaceSearch for NaverMapSearch {
|
||||
fn name(&self) -> &'static str {
|
||||
"naver"
|
||||
}
|
||||
|
||||
async fn search(&self, query: &str) -> anyhow::Result<Vec<PlaceCandidate>> {
|
||||
self.search_near(query, None).await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct InstantResp {
|
||||
#[serde(default)]
|
||||
place: Vec<InstantPlace>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct InstantPlace {
|
||||
id: String,
|
||||
title: String,
|
||||
#[serde(default)]
|
||||
ctg: String,
|
||||
#[serde(default)]
|
||||
jibun_address: String,
|
||||
#[serde(default)]
|
||||
road_address: String,
|
||||
x: String,
|
||||
y: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parses_apollo_snippet() {
|
||||
let html = r#"<script>window.__APOLLO_STATE__ = {"PlaceListBusinessesItem:37910590":{"id":"37910590","name":"성수동대림창고갤러리","category":"카페,디저트","fullAddress":"서울특별시 성동구 성수이로 78","roadAddress":"성수이로 78","virtualPhone":"0507-1390-9669","x":"127.0563952","y":"37.5417036"}};</script>"#;
|
||||
let list = parse_apollo_place_list(html);
|
||||
assert_eq!(list.len(), 1);
|
||||
assert_eq!(list[0].provider_id, "37910590");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
//! Naver Place photos + info/review text (unofficial, verified 2026-11-04).
|
||||
//!
|
||||
//! Fetches `https://m.place.naver.com/place/{id}/{home,photo,review/visitor}` (follows 302 to
|
||||
//! `/restaurant/{id}/...` or `/cafe/{id}/...`) and extracts image URLs on `*-phinf.pstatic.net`
|
||||
//! plus descriptive text from `window.__APOLLO_STATE__`.
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{PhotoSourceId, Place, RawPhoto, SourceOutput, TextSnippet};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::{http, naver_map, PhotoSource};
|
||||
|
||||
const PHINF_HOSTS: &[&str] = &[
|
||||
r"ldb-phinf\.pstatic\.net",
|
||||
r"pup-review-phinf\.pstatic\.net",
|
||||
r"naverbooking-phinf\.pstatic\.net",
|
||||
];
|
||||
|
||||
pub struct NaverPlacePhotos {
|
||||
client: reqwest::Client,
|
||||
}
|
||||
|
||||
impl Default for NaverPlacePhotos {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl NaverPlacePhotos {
|
||||
pub fn new() -> Self {
|
||||
Self { client: http::scraping_client() }
|
||||
}
|
||||
|
||||
async fn fetch_tab(&self, place_id: &str, tab: &str) -> anyhow::Result<(String, String)> {
|
||||
let url = format!("https://m.place.naver.com/place/{place_id}/{tab}");
|
||||
let resp = self
|
||||
.client
|
||||
.get(&url)
|
||||
.header(reqwest::header::USER_AGENT, http::MOBILE_UA)
|
||||
.header(reqwest::header::REFERER, "https://m.place.naver.com/")
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?;
|
||||
let final_url = resp.url().to_string();
|
||||
Ok((final_url, resp.text().await?))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PhotoSource for NaverPlacePhotos {
|
||||
fn id(&self) -> PhotoSourceId {
|
||||
PhotoSourceId::NaverPlace
|
||||
}
|
||||
|
||||
async fn collect(&self, place: &Place, limit: usize) -> anyhow::Result<SourceOutput> {
|
||||
let Some(place_id) = place.naver_place_id.as_deref() else {
|
||||
anyhow::bail!("naver place id not resolved");
|
||||
};
|
||||
let mut seen = HashSet::new();
|
||||
let mut photos = Vec::new();
|
||||
let mut texts = Vec::new();
|
||||
|
||||
for tab in ["photo", "review/visitor", "information", "home"] {
|
||||
if photos.len() >= limit {
|
||||
break;
|
||||
}
|
||||
let (page_url, html) = match self.fetch_tab(place_id, tab).await {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
tracing::debug!(place_id, tab, "naver place tab failed: {e}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
parse_naver_place_html(&html, &page_url, limit, &mut seen, &mut photos, &mut texts);
|
||||
}
|
||||
|
||||
Ok(SourceOutput { photos, texts })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_naver_place_html(
|
||||
html: &str,
|
||||
page_url: &str,
|
||||
limit: usize,
|
||||
seen: &mut HashSet<String>,
|
||||
photos: &mut Vec<RawPhoto>,
|
||||
texts: &mut Vec<TextSnippet>,
|
||||
) {
|
||||
if let Some(state) = naver_map::extract_apollo_state(html) {
|
||||
extract_apollo_texts_and_photos(&state, page_url, limit, seen, photos, texts);
|
||||
}
|
||||
for raw_url in http::extract_image_urls(html, PHINF_HOSTS) {
|
||||
if photos.len() >= limit {
|
||||
break;
|
||||
}
|
||||
if is_noise_image(&raw_url) {
|
||||
continue;
|
||||
}
|
||||
let clean = normalize_phinf_url(&raw_url);
|
||||
if seen.insert(clean.clone()) {
|
||||
photos.push(RawPhoto {
|
||||
source: PhotoSourceId::NaverPlace,
|
||||
image_url: upgrade_phinf_size(&clean),
|
||||
page_url: page_url.to_string(),
|
||||
caption: String::new(),
|
||||
referer: Some("https://m.place.naver.com/".into()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_apollo_texts_and_photos(
|
||||
state: &Value,
|
||||
page_url: &str,
|
||||
limit: usize,
|
||||
seen: &mut HashSet<String>,
|
||||
photos: &mut Vec<RawPhoto>,
|
||||
texts: &mut Vec<TextSnippet>,
|
||||
) {
|
||||
let Some(obj) = state.as_object() else { return };
|
||||
let mut text_lines = Vec::new();
|
||||
for (_k, v) in obj {
|
||||
let Some(map) = v.as_object() else { continue };
|
||||
for field in ["description", "introduction", "conveniences", "parking", "direction", "body", "text"] {
|
||||
if let Some(val) = map.get(field) {
|
||||
match val {
|
||||
Value::String(s) if s.chars().count() >= 6 => text_lines.push(s.clone()),
|
||||
Value::Array(arr) => {
|
||||
let joined: Vec<&str> = arr.iter().filter_map(Value::as_str).collect();
|
||||
if !joined.is_empty() {
|
||||
text_lines.push(joined.join(", "));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Review or photo entries often carry both `body`/`text` and `media`/`originUrl`.
|
||||
if photos.len() < limit {
|
||||
if let Some(url) = map
|
||||
.get("originUrl")
|
||||
.or_else(|| map.get("imageUrl"))
|
||||
.and_then(Value::as_str)
|
||||
.filter(|u| u.contains("-phinf.pstatic.net") && !is_noise_image(u))
|
||||
{
|
||||
let clean = normalize_phinf_url(url);
|
||||
if seen.insert(clean.clone()) {
|
||||
let caption = map
|
||||
.get("body")
|
||||
.or_else(|| map.get("text"))
|
||||
.or_else(|| map.get("description"))
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default()
|
||||
.chars()
|
||||
.take(200)
|
||||
.collect();
|
||||
photos.push(RawPhoto {
|
||||
source: PhotoSourceId::NaverPlace,
|
||||
image_url: upgrade_phinf_size(&clean),
|
||||
page_url: page_url.to_string(),
|
||||
caption,
|
||||
referer: Some("https://m.place.naver.com/".into()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !text_lines.is_empty() {
|
||||
text_lines.dedup();
|
||||
let combined: String = text_lines.join("\n").chars().take(3000).collect();
|
||||
texts.push(TextSnippet {
|
||||
source: PhotoSourceId::NaverPlace,
|
||||
url: page_url.to_string(),
|
||||
text: combined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn normalize_phinf_url(u: &str) -> String {
|
||||
u.split('?').next().unwrap_or(u).to_string()
|
||||
}
|
||||
|
||||
fn upgrade_phinf_size(clean_url: &str) -> String {
|
||||
format!("{clean_url}?type=w1200_60_sharpen")
|
||||
}
|
||||
|
||||
fn is_noise_image(u: &str) -> bool {
|
||||
let lower = u.to_ascii_lowercase();
|
||||
lower.contains("profile") || lower.contains("icon") || lower.contains("logo") || lower.contains(" default")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn extracts_apollo_and_regex_photos() {
|
||||
let html = r#"<script>window.__APOLLO_STATE__ = {"VisitorReview:1":{"body":"2층 창가 자리가 넓어요","originUrl":"https:\u002F\u002Fpup-review-phinf.pstatic.net\u002F2026\u002Fa.jpg?type=w300"}};</script><img src="https://ldb-phinf.pstatic.net/2025/b.jpg"/>"#;
|
||||
let mut seen = HashSet::new();
|
||||
let mut photos = Vec::new();
|
||||
let mut texts = Vec::new();
|
||||
parse_naver_place_html(html, "https://m.place.naver.com/place/1/photo", 10, &mut seen, &mut photos, &mut texts);
|
||||
assert_eq!(photos.len(), 2);
|
||||
assert_eq!(photos[0].caption, "2층 창가 자리가 넓어요");
|
||||
assert_eq!(texts.len(), 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//! Naver Cloud Platform Maps — Geocoding (official). Address normalization/verification only.
|
||||
//! Docs: https://api.ncloud-docs.com/docs/application-maps-geocoding
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
const URL: &str = "https://maps.apigw.ntruss.com/map-geocode/v2/geocode";
|
||||
|
||||
pub struct NcpGeocode {
|
||||
client: reqwest::Client,
|
||||
id: String,
|
||||
secret: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GeocodeResult {
|
||||
pub road_address: String,
|
||||
pub jibun_address: String,
|
||||
pub lat: f64,
|
||||
pub lng: f64,
|
||||
}
|
||||
|
||||
impl NcpGeocode {
|
||||
pub fn new(id: impl Into<String>, secret: impl Into<String>) -> Self {
|
||||
Self { client: crate::http::api_client(), id: id.into(), secret: secret.into() }
|
||||
}
|
||||
|
||||
pub async fn geocode(&self, query: &str) -> anyhow::Result<Option<GeocodeResult>> {
|
||||
let resp = self
|
||||
.client
|
||||
.get(URL)
|
||||
.header("x-ncp-apigw-api-key-id", &self.id)
|
||||
.header("x-ncp-apigw-api-key", &self.secret)
|
||||
.header("Accept", "application/json")
|
||||
.query(&[("query", query)])
|
||||
.send()
|
||||
.await?;
|
||||
let status = resp.status();
|
||||
if !status.is_success() {
|
||||
anyhow::bail!("ncp geocode {status}: {}", resp.text().await.unwrap_or_default());
|
||||
}
|
||||
let r: Resp = resp.json().await?;
|
||||
Ok(r.addresses.into_iter().next().map(|a| GeocodeResult {
|
||||
road_address: a.road_address,
|
||||
jibun_address: a.jibun_address,
|
||||
lat: a.y.parse().unwrap_or_default(),
|
||||
lng: a.x.parse().unwrap_or_default(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Resp {
|
||||
#[serde(default)]
|
||||
addresses: Vec<Addr>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Addr {
|
||||
#[serde(default)]
|
||||
road_address: String,
|
||||
#[serde(default)]
|
||||
jibun_address: String,
|
||||
x: String,
|
||||
y: String,
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
//! Text helpers: name normalization/similarity, distance, floor keyword extraction.
|
||||
|
||||
use regex::Regex;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
/// Lowercase, strip whitespace/punctuation so "스타벅스 성수점" ≈ "스타벅스성수점".
|
||||
pub fn normalize_name(s: &str) -> String {
|
||||
s.chars()
|
||||
.filter(|c| c.is_alphanumeric())
|
||||
.flat_map(|c| c.to_lowercase())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Similarity in 0..=1 based on character bigram Dice coefficient.
|
||||
pub fn name_similarity(a: &str, b: &str) -> f32 {
|
||||
let a = normalize_name(a);
|
||||
let b = normalize_name(b);
|
||||
if a.is_empty() || b.is_empty() {
|
||||
return 0.0;
|
||||
}
|
||||
if a == b {
|
||||
return 1.0;
|
||||
}
|
||||
if a.contains(&b) || b.contains(&a) {
|
||||
return 0.9;
|
||||
}
|
||||
let bigrams = |s: &str| -> Vec<(char, char)> {
|
||||
let cs: Vec<char> = s.chars().collect();
|
||||
cs.windows(2).map(|w| (w[0], w[1])).collect()
|
||||
};
|
||||
let ba = bigrams(&a);
|
||||
let mut bb = bigrams(&b);
|
||||
if ba.is_empty() || bb.is_empty() {
|
||||
return 0.0;
|
||||
}
|
||||
let total = ba.len() + bb.len();
|
||||
let mut hits = 0;
|
||||
for g in &ba {
|
||||
if let Some(pos) = bb.iter().position(|x| x == g) {
|
||||
bb.swap_remove(pos);
|
||||
hits += 1;
|
||||
}
|
||||
}
|
||||
(2 * hits) as f32 / total as f32
|
||||
}
|
||||
|
||||
/// Great-circle distance in meters.
|
||||
pub fn haversine_m(lat1: f64, lng1: f64, lat2: f64, lng2: f64) -> f64 {
|
||||
let r = 6_371_000.0_f64;
|
||||
let (p1, p2) = (lat1.to_radians(), lat2.to_radians());
|
||||
let dp = (lat2 - lat1).to_radians();
|
||||
let dl = (lng2 - lng1).to_radians();
|
||||
let a = (dp / 2.0).sin().powi(2) + p1.cos() * p2.cos() * (dl / 2.0).sin().powi(2);
|
||||
2.0 * r * a.sqrt().asin()
|
||||
}
|
||||
|
||||
static FLOOR_RE: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(r"(?x)
|
||||
(?P<b>지하\s*(?P<bn>\d)\s*층|B(?P<bn2>\d)\b|지하층)
|
||||
| (?P<n>\d{1,2})\s*(?:층|F\b|f\b)
|
||||
| (?P<roof>루프탑|옥상)
|
||||
").unwrap()
|
||||
});
|
||||
|
||||
/// Floor mentions found in text: (level, snippet). Rooftop = `domain::ROOFTOP_LEVEL`.
|
||||
pub fn floor_mentions(text: &str) -> Vec<(i32, String)> {
|
||||
let mut out = Vec::new();
|
||||
for caps in FLOOR_RE.captures_iter(text) {
|
||||
let m = caps.get(0).unwrap();
|
||||
let level = if caps.name("b").is_some() {
|
||||
caps.name("bn")
|
||||
.or(caps.name("bn2"))
|
||||
.and_then(|x| x.as_str().parse::<i32>().ok())
|
||||
.map(|n| -n)
|
||||
.unwrap_or(-1)
|
||||
} else if let Some(n) = caps.name("n") {
|
||||
match n.as_str().parse::<i32>() {
|
||||
Ok(n) if (1..=20).contains(&n) => n,
|
||||
_ => continue,
|
||||
}
|
||||
} else if caps.name("roof").is_some() {
|
||||
domain::ROOFTOP_LEVEL
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
out.push((level, snippet_around(text, m.start(), m.end(), 40)));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Text window of roughly `radius` chars around a byte range, on char boundaries.
|
||||
pub fn snippet_around(text: &str, start: usize, end: usize, radius: usize) -> String {
|
||||
let mut s = start;
|
||||
for _ in 0..radius {
|
||||
if s == 0 {
|
||||
break;
|
||||
}
|
||||
s -= 1;
|
||||
while !text.is_char_boundary(s) {
|
||||
s -= 1;
|
||||
}
|
||||
}
|
||||
let mut e = end;
|
||||
for _ in 0..radius {
|
||||
if e >= text.len() {
|
||||
break;
|
||||
}
|
||||
e += 1;
|
||||
while e < text.len() && !text.is_char_boundary(e) {
|
||||
e += 1;
|
||||
}
|
||||
}
|
||||
text[s..e].split_whitespace().collect::<Vec<_>>().join(" ")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn similarity() {
|
||||
assert!(name_similarity("스타벅스 성수점", "스타벅스성수점") > 0.99);
|
||||
assert!(name_similarity("대림창고", "대림창고 갤러리컬럼") >= 0.9);
|
||||
assert!(name_similarity("블루보틀", "스타벅스") < 0.2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn floors() {
|
||||
let m = floor_mentions("1층은 주문, 2층 좌석이 넓고 루프탑도 있어요. 지하 1층 화장실");
|
||||
let levels: Vec<i32> = m.iter().map(|x| x.0).collect();
|
||||
assert_eq!(levels, vec![1, 2, domain::ROOFTOP_LEVEL, -1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn distance() {
|
||||
let d = haversine_m(37.5446, 127.0557, 37.5450, 127.0557);
|
||||
assert!((d - 44.5).abs() < 2.0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user