6
6
"""
7
7
8
8
import time
9
- from typing import Iterable , Iterator , List , Sequence
9
+ from typing import Dict , Iterator , List , Sequence
10
10
11
11
import dlt
12
12
from dlt .common import logger
13
- from dlt .common .typing import DictStrAny , DictStrStr
13
+ from dlt .common .typing import DictStrAny
14
14
from dlt .sources import DltResource
15
15
16
16
from .helpers import get_stats_with_retry , parse_response
17
17
18
18
19
19
@dlt .source (name = "bing_webmaster" )
20
20
def source (
21
- site_urls : List [str ] = None , site_url_pages : Iterable [DictStrStr ] = None
21
+ site_urls : List [str ] = dlt .config .value ,
22
+ site_url_pages : List [Dict [str ,str ]] = dlt .config .value ,
22
23
) -> Sequence [DltResource ]:
23
24
"""
24
25
A dlt source for the Bing Webmaster api.
25
26
It groups resources for the APIs which return organic search traffic statistics
26
27
Args:
27
28
site_urls: List[str]: A list of site_urls, e.g, ["dlthub.com", "dlthub.de"]. Use this if you need the weekly traffic per site_url and page
28
- site_url_pages: Iterable[DictStrStr ]: A list of pairs of site_url and page. Use this if you need the weekly traffic per site_url, page, and query
29
+ site_url_pages: Iterable[Dict[str, str] ]: A list of pairs of site_url and page. Use this if you need the weekly traffic per site_url, page, and query
29
30
Returns:
30
31
Sequence[DltResource]: A sequence of resources that can be selected from including page_stats and page_query_stats.
31
32
"""
@@ -42,7 +43,7 @@ def source(
42
43
table_name = "bing_page_stats" ,
43
44
)
44
45
def page_stats (
45
- site_urls : List [str ], api_key : str = dlt .secrets .value
46
+ site_urls : List [str ], api_key : str = dlt .secrets .value # here # investigate
46
47
) -> Iterator [Iterator [DictStrAny ]]:
47
48
"""
48
49
Yields detailed traffic statistics for top pages belonging to a site_url
@@ -70,7 +71,7 @@ def page_stats(
70
71
table_name = "bing_page_query_stats" ,
71
72
)
72
73
def page_query_stats (
73
- site_url_pages : Iterable [ DictStrStr ],
74
+ site_url_pages : List [ Dict [ str , str ] ],
74
75
api_key : str = dlt .secrets .value ,
75
76
) -> Iterator [Iterator [DictStrAny ]]:
76
77
"""
@@ -80,7 +81,7 @@ def page_query_stats(
80
81
https://learn.microsoft.com/en-us/dotnet/api/microsoft.bing.webmaster.api.interfaces.iwebmasterapi.getpagequerystats
81
82
82
83
Args:
83
- site_url_page (Iterable[DictStrStr ]): Iterable of site_url and pages to retrieve statistics for. Can be result of a SQL query, a parsed sitemap, etc.
84
+ site_url_page (List[Dict[str,str] ]): Iterable of site_url and pages to retrieve statistics for. Can be result of a SQL query, a parsed sitemap, etc.
84
85
Yields:
85
86
Iterator[Dict[str, Any]]: An iterator over list of organic traffic statistics.
86
87
"""
0 commit comments