Skip to content

Instantly share code, notes, and snippets.

@JinKwonJeon
Last active August 5, 2024 07:22
Show Gist options
  • Select an option

  • Save JinKwonJeon/309a29d311bd057ec00358927e0f711e to your computer and use it in GitHub Desktop.

Select an option

Save JinKwonJeon/309a29d311bd057ec00358927e0f711e to your computer and use it in GitHub Desktop.
NaverShoppingCount 함수 (PowerQuery M)
(Keywords as text) =>
let
// Step 1: 네이버 쇼핑 메인 페이지에서 키워드 검색 결과를 바이너리 형식으로 가져오기
NShoppingMain = Web.BrowserContents("https://search.shopping.naver.com/search/all?query="&Keywords),
// Step 2: 'subFilters' 문자열의 위치 찾기
CatPos = Text.PositionOf(NShoppingMain, "subFilters"),
// Step 3: 'subFilters' 이후의 텍스트 가져오기
TextAfterMainFilter = Text.Middle(NShoppingMain, CatPos, Text.Length(NShoppingMain) - CatPos),
// Step 4: 'productCount":' 문자열의 위치 찾기
CountPos = Text.PositionOf(TextAfterMainFilter, "productCount"":"),
// Step 5: 'productCount":' 이후의 텍스트 가져오기
TextAfterCount = Text.Middle(TextAfterMainFilter, CountPos, Text.Length(TextAfterMainFilter) - CountPos),
// Step 6: '},' 문자열의 위치 찾기
CommaPos = Text.PositionOf(TextAfterCount, "},"),
// Step 7: 'productCount' 값을 숫자 형식으로 변환
NaverShoppingCount = Number.From(Text.Middle(TextAfterCount, 14, CommaPos - 14))
in
NaverShoppingCount
@JinKwonJeon

Copy link
Copy Markdown
Author

2024-08-05 / WebBrowserContents 함수로 웹 데이터 호출 방식 변경

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment