scrapebadger-cli 0.29.0__tar.gz → 0.30.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/CHANGELOG.md +6 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/PKG-INFO +1 -1
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/pyproject.toml +1 -1
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/client.py +9 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/google.py +215 -5
- scrapebadger_cli-0.30.0/tests/test_google_light_search.py +61 -0
- scrapebadger_cli-0.29.0/tests/test_google_light_search.py +0 -22
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/.gitignore +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/README.md +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/__init__.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/availability.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/__init__.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/agent.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/airbnb.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/aliexpress.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/amazon.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/apartments.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/app_store.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/asos.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/auth.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/autoscout24.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/baidu.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/bestbuy.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/bing.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/booking.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/brave.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/chatgpt.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/copilot.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/depop.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/duckduckgo.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/ebay.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/etsy.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/facebook.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/gemini.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/github.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/google_play.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/gumtree.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/idealista.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/immobiliare.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/init.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/instagram.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/leboncoin.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/linkedin.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/loopnet.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/naver.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/onboarding.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/perplexity.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/realtor.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/reddit.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/redfin.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/stream.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/target.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/tiktok.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/twitter.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/vinted.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/wallapop.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/walmart.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/web.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/yahoo.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/yandex.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/yelp.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/youtube.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/zillow.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/config.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/main.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/output.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/results.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/views.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/conftest.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_agent_features.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_autoscout24_commands.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_brave.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_cli_availability.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_copilot_commands.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_github.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_naver.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_perplexity_strict_country.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_tiktok_pagination.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_vinted_image_search.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/tests/test_yelp_commands.py +0 -0
- {scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/uv.lock +0 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.30.0 — 2026-11-07
|
|
4
|
+
|
|
5
|
+
- Expose Google Search and Light targeting, advanced filters, and `--no-cache`.
|
|
6
|
+
- Add `--response-format html` for raw search pages, including Google verticals.
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
## 0.29.0 — 2026-11-07
|
|
4
10
|
|
|
5
11
|
- Add AutoScout24 listing details and GitHub repository operations.
|
|
@@ -45,6 +45,15 @@ def api_get(path: str, params: dict[str, Any] | None = None, *, save: bool = Tru
|
|
|
45
45
|
return _handle_response(resp, path if save else None)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def api_get_raw(path: str, params: dict[str, Any] | None = None) -> bytes:
|
|
49
|
+
"""GET a raw response, preserving the usual authentication and error handling."""
|
|
50
|
+
clean = {k: v for k, v in (params or {}).items() if v is not None}
|
|
51
|
+
resp = _get_client().get(path, params=clean or None)
|
|
52
|
+
if resp.status_code >= 400:
|
|
53
|
+
_handle_response(resp)
|
|
54
|
+
return resp.content
|
|
55
|
+
|
|
56
|
+
|
|
48
57
|
def api_post(
|
|
49
58
|
path: str, json_body: dict[str, Any] | None = None, *, save: bool = True
|
|
50
59
|
) -> dict | list:
|
|
@@ -15,7 +15,7 @@ Typical workflow:
|
|
|
15
15
|
|
|
16
16
|
import typer
|
|
17
17
|
|
|
18
|
-
from scrapebadger_cli.client import api_get
|
|
18
|
+
from scrapebadger_cli.client import api_get, api_get_raw
|
|
19
19
|
from scrapebadger_cli.output import render
|
|
20
20
|
|
|
21
21
|
app = typer.Typer(no_args_is_help=True)
|
|
@@ -46,13 +46,116 @@ def search(
|
|
|
46
46
|
"--ai-overview",
|
|
47
47
|
help="Chase deferred AI Overview page_token when the SERP defers it",
|
|
48
48
|
),
|
|
49
|
+
uule: str | None = typer.Option(None, "--uule", help="Encoded Google location."),
|
|
50
|
+
lr: str | None = typer.Option(None, "--lr", help="Result language restrict."),
|
|
51
|
+
filter: int | None = typer.Option(None, "--filter", help="Omitted-results filter: 0 or 1."),
|
|
52
|
+
nfpr: int | None = typer.Option(None, "--nfpr", help="Disable spelling correction."),
|
|
53
|
+
user_agent: str | None = typer.Option(None, "--user-agent", help="Custom User-Agent."),
|
|
54
|
+
cr: str | None = typer.Option(None, "--cr", help="Country restrict."),
|
|
55
|
+
ludocid: str | None = typer.Option(None, "--ludocid", help="Place CID."),
|
|
56
|
+
lsig: str | None = typer.Option(None, "--lsig", help="Map view ID."),
|
|
57
|
+
kgmid: str | None = typer.Option(None, "--kgmid", help="Knowledge Graph entity ID."),
|
|
58
|
+
si: str | None = typer.Option(None, "--si", help="Cached Google parameters."),
|
|
59
|
+
ibp: str | None = typer.Option(None, "--ibp", help="Layout control."),
|
|
60
|
+
uds: str | None = typer.Option(None, "--uds", help="Google filter string."),
|
|
61
|
+
google_domain: str | None = typer.Option(
|
|
62
|
+
None,
|
|
63
|
+
"--google-domain",
|
|
64
|
+
help="Alias for domain; Google requests use google.com with country targeting.",
|
|
65
|
+
),
|
|
66
|
+
lat: float | None = typer.Option(
|
|
67
|
+
None, "--lat", help="Latitude; supply together with lon instead of location or uule."
|
|
68
|
+
),
|
|
69
|
+
lon: float | None = typer.Option(None, "--lon", help="Longitude; supply together with lat."),
|
|
70
|
+
radius: float | None = typer.Option(
|
|
71
|
+
None,
|
|
72
|
+
"--radius",
|
|
73
|
+
help="Location accuracy in meters; requires lat/lon or a named city with a known center.",
|
|
74
|
+
),
|
|
75
|
+
color_scheme: str | None = typer.Option(None, "--color-scheme", help="Google color scheme."),
|
|
76
|
+
tbm: str | None = typer.Option(
|
|
77
|
+
None,
|
|
78
|
+
"--tbm",
|
|
79
|
+
help="Google search type. Use output=html for verticals; dedicated APIs provide parsed vertical results.",
|
|
80
|
+
),
|
|
81
|
+
udm: str | None = typer.Option(
|
|
82
|
+
None,
|
|
83
|
+
"--udm",
|
|
84
|
+
help="Google result filter: 14 web, 18 forums. Other verticals require output=html.",
|
|
85
|
+
),
|
|
86
|
+
no_cache: bool = typer.Option(
|
|
87
|
+
False, "--no-cache", help="Bypass result caches and request a fresh Google fetch."
|
|
88
|
+
),
|
|
89
|
+
as_dt: str | None = typer.Option(
|
|
90
|
+
None, "--as-dt", help="Site restriction mode: i includes, e excludes as_sitesearch."
|
|
91
|
+
),
|
|
92
|
+
as_epq: str | None = typer.Option(None, "--as-epq", help="Exact phrase."),
|
|
93
|
+
as_eq: str | None = typer.Option(None, "--as-eq", help="Words to exclude."),
|
|
94
|
+
as_lq: str | None = typer.Option(
|
|
95
|
+
None, "--as-lq", help="Find pages linking to this URL; availability depends on Google."
|
|
96
|
+
),
|
|
97
|
+
as_nlo: str | None = typer.Option(None, "--as-nlo", help="Numeric range minimum."),
|
|
98
|
+
as_nhi: str | None = typer.Option(None, "--as-nhi", help="Numeric range maximum."),
|
|
99
|
+
as_oq: str | None = typer.Option(None, "--as-oq", help="Match any of these words."),
|
|
100
|
+
as_q: str | None = typer.Option(None, "--as-q", help="Additional query words."),
|
|
101
|
+
as_qdr: str | None = typer.Option(None, "--as-qdr", help="Time range, such as d, w, m or y1."),
|
|
102
|
+
as_rq: str | None = typer.Option(
|
|
103
|
+
None, "--as-rq", help="Related URL; availability depends on Google."
|
|
104
|
+
),
|
|
105
|
+
as_sitesearch: str | None = typer.Option(
|
|
106
|
+
None, "--as-sitesearch", help="Restrict results to a site."
|
|
107
|
+
),
|
|
108
|
+
expand_related_questions: str | None = typer.Option(
|
|
109
|
+
None,
|
|
110
|
+
"--expand-related-questions",
|
|
111
|
+
help="true or the number of People Also Ask answers to open.",
|
|
112
|
+
),
|
|
113
|
+
response_format: str = typer.Option(
|
|
114
|
+
"json", "--response-format", help="API format: json or html"
|
|
115
|
+
),
|
|
49
116
|
fmt: str = FMT,
|
|
50
117
|
fields: str | None = FIELDS,
|
|
51
118
|
) -> None:
|
|
52
119
|
"""Google web search (SERP)."""
|
|
53
|
-
|
|
120
|
+
if response_format not in ("json", "html"):
|
|
121
|
+
raise typer.BadParameter("--response-format must be json or html")
|
|
122
|
+
fetch = api_get_raw if response_format == "html" else api_get
|
|
123
|
+
data = fetch(
|
|
54
124
|
"/v1/google/search",
|
|
55
125
|
{
|
|
126
|
+
"uule": uule,
|
|
127
|
+
"lr": lr,
|
|
128
|
+
"filter": filter,
|
|
129
|
+
"nfpr": nfpr,
|
|
130
|
+
"user_agent": user_agent,
|
|
131
|
+
"cr": cr,
|
|
132
|
+
"ludocid": ludocid,
|
|
133
|
+
"lsig": lsig,
|
|
134
|
+
"kgmid": kgmid,
|
|
135
|
+
"si": si,
|
|
136
|
+
"ibp": ibp,
|
|
137
|
+
"uds": uds,
|
|
138
|
+
"google_domain": google_domain,
|
|
139
|
+
"lat": lat,
|
|
140
|
+
"lon": lon,
|
|
141
|
+
"radius": radius,
|
|
142
|
+
"color_scheme": color_scheme,
|
|
143
|
+
"tbm": tbm,
|
|
144
|
+
"udm": udm,
|
|
145
|
+
"no_cache": no_cache,
|
|
146
|
+
"as_dt": as_dt,
|
|
147
|
+
"as_epq": as_epq,
|
|
148
|
+
"as_eq": as_eq,
|
|
149
|
+
"as_lq": as_lq,
|
|
150
|
+
"as_nlo": as_nlo,
|
|
151
|
+
"as_nhi": as_nhi,
|
|
152
|
+
"as_oq": as_oq,
|
|
153
|
+
"as_q": as_q,
|
|
154
|
+
"as_qdr": as_qdr,
|
|
155
|
+
"as_rq": as_rq,
|
|
156
|
+
"as_sitesearch": as_sitesearch,
|
|
157
|
+
"expand_related_questions": expand_related_questions,
|
|
158
|
+
"output": response_format,
|
|
56
159
|
"q": q,
|
|
57
160
|
"gl": gl,
|
|
58
161
|
"hl": hl,
|
|
@@ -66,7 +169,10 @@ def search(
|
|
|
66
169
|
"ai_overview": ai_overview if ai_overview else None,
|
|
67
170
|
},
|
|
68
171
|
)
|
|
69
|
-
|
|
172
|
+
if isinstance(data, bytes):
|
|
173
|
+
typer.echo(data.decode("utf-8"))
|
|
174
|
+
else:
|
|
175
|
+
render(data, fmt, fields)
|
|
70
176
|
|
|
71
177
|
|
|
72
178
|
@app.command(name="light-search")
|
|
@@ -79,13 +185,114 @@ def light_search(
|
|
|
79
185
|
domain: str | None = typer.Option(None, "--domain", help="Google domain"),
|
|
80
186
|
location: str | None = typer.Option(None, "--location", help="City-level geo-targeting"),
|
|
81
187
|
safe: str | None = typer.Option(None, "--safe", help="off / active"),
|
|
188
|
+
uule: str | None = typer.Option(None, "--uule", help="Encoded Google location."),
|
|
189
|
+
lr: str | None = typer.Option(None, "--lr", help="Result language restrict."),
|
|
190
|
+
tbs: str | None = typer.Option(None, "--tbs", help="Google search filters."),
|
|
191
|
+
filter: int | None = typer.Option(None, "--filter", help="Omitted-results filter: 0 or 1."),
|
|
192
|
+
nfpr: int | None = typer.Option(None, "--nfpr", help="Disable spelling correction."),
|
|
193
|
+
device: str | None = typer.Option(None, "--device", help="Device target."),
|
|
194
|
+
user_agent: str | None = typer.Option(None, "--user-agent", help="Custom User-Agent."),
|
|
195
|
+
cr: str | None = typer.Option(None, "--cr", help="Country restrict."),
|
|
196
|
+
ludocid: str | None = typer.Option(None, "--ludocid", help="Place CID."),
|
|
197
|
+
lsig: str | None = typer.Option(None, "--lsig", help="Map view ID."),
|
|
198
|
+
kgmid: str | None = typer.Option(None, "--kgmid", help="Knowledge Graph entity ID."),
|
|
199
|
+
si: str | None = typer.Option(None, "--si", help="Cached Google parameters."),
|
|
200
|
+
ibp: str | None = typer.Option(None, "--ibp", help="Layout control."),
|
|
201
|
+
uds: str | None = typer.Option(None, "--uds", help="Google filter string."),
|
|
202
|
+
google_domain: str | None = typer.Option(
|
|
203
|
+
None,
|
|
204
|
+
"--google-domain",
|
|
205
|
+
help="Alias for domain; Google requests use google.com with country targeting.",
|
|
206
|
+
),
|
|
207
|
+
lat: float | None = typer.Option(
|
|
208
|
+
None, "--lat", help="Latitude; supply together with lon instead of location or uule."
|
|
209
|
+
),
|
|
210
|
+
lon: float | None = typer.Option(None, "--lon", help="Longitude; supply together with lat."),
|
|
211
|
+
radius: float | None = typer.Option(
|
|
212
|
+
None,
|
|
213
|
+
"--radius",
|
|
214
|
+
help="Location accuracy in meters; requires lat/lon or a named city with a known center.",
|
|
215
|
+
),
|
|
216
|
+
color_scheme: str | None = typer.Option(None, "--color-scheme", help="Google color scheme."),
|
|
217
|
+
tbm: str | None = typer.Option(
|
|
218
|
+
None,
|
|
219
|
+
"--tbm",
|
|
220
|
+
help="Google search type. Use output=html for verticals; dedicated APIs provide parsed vertical results.",
|
|
221
|
+
),
|
|
222
|
+
udm: str | None = typer.Option(
|
|
223
|
+
None,
|
|
224
|
+
"--udm",
|
|
225
|
+
help="Google result filter: 14 web, 18 forums. Other verticals require output=html.",
|
|
226
|
+
),
|
|
227
|
+
no_cache: bool = typer.Option(
|
|
228
|
+
False, "--no-cache", help="Bypass result caches and request a fresh Google fetch."
|
|
229
|
+
),
|
|
230
|
+
as_dt: str | None = typer.Option(
|
|
231
|
+
None, "--as-dt", help="Site restriction mode: i includes, e excludes as_sitesearch."
|
|
232
|
+
),
|
|
233
|
+
as_epq: str | None = typer.Option(None, "--as-epq", help="Exact phrase."),
|
|
234
|
+
as_eq: str | None = typer.Option(None, "--as-eq", help="Words to exclude."),
|
|
235
|
+
as_lq: str | None = typer.Option(
|
|
236
|
+
None, "--as-lq", help="Find pages linking to this URL; availability depends on Google."
|
|
237
|
+
),
|
|
238
|
+
as_nlo: str | None = typer.Option(None, "--as-nlo", help="Numeric range minimum."),
|
|
239
|
+
as_nhi: str | None = typer.Option(None, "--as-nhi", help="Numeric range maximum."),
|
|
240
|
+
as_oq: str | None = typer.Option(None, "--as-oq", help="Match any of these words."),
|
|
241
|
+
as_q: str | None = typer.Option(None, "--as-q", help="Additional query words."),
|
|
242
|
+
as_qdr: str | None = typer.Option(None, "--as-qdr", help="Time range, such as d, w, m or y1."),
|
|
243
|
+
as_rq: str | None = typer.Option(
|
|
244
|
+
None, "--as-rq", help="Related URL; availability depends on Google."
|
|
245
|
+
),
|
|
246
|
+
as_sitesearch: str | None = typer.Option(
|
|
247
|
+
None, "--as-sitesearch", help="Restrict results to a site."
|
|
248
|
+
),
|
|
249
|
+
response_format: str = typer.Option(
|
|
250
|
+
"json", "--response-format", help="API format: json or html"
|
|
251
|
+
),
|
|
82
252
|
fmt: str = FMT,
|
|
83
253
|
fields: str | None = FIELDS,
|
|
84
254
|
) -> None:
|
|
85
255
|
"""Google Light Search — organic + related searches, 10 credits (regular Search: 20)."""
|
|
86
|
-
|
|
256
|
+
if response_format not in ("json", "html"):
|
|
257
|
+
raise typer.BadParameter("--response-format must be json or html")
|
|
258
|
+
fetch = api_get_raw if response_format == "html" else api_get
|
|
259
|
+
data = fetch(
|
|
87
260
|
"/v1/google/light/search",
|
|
88
261
|
{
|
|
262
|
+
"uule": uule,
|
|
263
|
+
"lr": lr,
|
|
264
|
+
"tbs": tbs,
|
|
265
|
+
"filter": filter,
|
|
266
|
+
"nfpr": nfpr,
|
|
267
|
+
"device": device,
|
|
268
|
+
"user_agent": user_agent,
|
|
269
|
+
"cr": cr,
|
|
270
|
+
"ludocid": ludocid,
|
|
271
|
+
"lsig": lsig,
|
|
272
|
+
"kgmid": kgmid,
|
|
273
|
+
"si": si,
|
|
274
|
+
"ibp": ibp,
|
|
275
|
+
"uds": uds,
|
|
276
|
+
"google_domain": google_domain,
|
|
277
|
+
"lat": lat,
|
|
278
|
+
"lon": lon,
|
|
279
|
+
"radius": radius,
|
|
280
|
+
"color_scheme": color_scheme,
|
|
281
|
+
"tbm": tbm,
|
|
282
|
+
"udm": udm,
|
|
283
|
+
"no_cache": no_cache,
|
|
284
|
+
"as_dt": as_dt,
|
|
285
|
+
"as_epq": as_epq,
|
|
286
|
+
"as_eq": as_eq,
|
|
287
|
+
"as_lq": as_lq,
|
|
288
|
+
"as_nlo": as_nlo,
|
|
289
|
+
"as_nhi": as_nhi,
|
|
290
|
+
"as_oq": as_oq,
|
|
291
|
+
"as_q": as_q,
|
|
292
|
+
"as_qdr": as_qdr,
|
|
293
|
+
"as_rq": as_rq,
|
|
294
|
+
"as_sitesearch": as_sitesearch,
|
|
295
|
+
"output": response_format,
|
|
89
296
|
"q": q,
|
|
90
297
|
"gl": gl,
|
|
91
298
|
"hl": hl,
|
|
@@ -96,7 +303,10 @@ def light_search(
|
|
|
96
303
|
"safe": safe,
|
|
97
304
|
},
|
|
98
305
|
)
|
|
99
|
-
|
|
306
|
+
if isinstance(data, bytes):
|
|
307
|
+
typer.echo(data.decode("utf-8"))
|
|
308
|
+
else:
|
|
309
|
+
render(data, fmt, fields)
|
|
100
310
|
|
|
101
311
|
|
|
102
312
|
# ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from unittest.mock import Mock
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
CliRunner = pytest.importorskip("typer.testing").CliRunner
|
|
6
|
+
google = pytest.importorskip(
|
|
7
|
+
"scrapebadger_cli.commands.google", reason="CLI is tested with its own installed package"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_light_search_uses_dedicated_route(monkeypatch):
|
|
12
|
+
call = Mock(return_value={"organic_results": []})
|
|
13
|
+
monkeypatch.setattr(google, "api_get", call)
|
|
14
|
+
monkeypatch.setattr(google, "render", Mock())
|
|
15
|
+
result = CliRunner().invoke(
|
|
16
|
+
google.app, ["light-search", "vinted api", "--gl", "us", "--start", "10"]
|
|
17
|
+
)
|
|
18
|
+
assert result.exit_code == 0, result.output
|
|
19
|
+
path, params = call.call_args.args
|
|
20
|
+
assert path == "/v1/google/light/search"
|
|
21
|
+
assert params["q"] == "vinted api" and params["start"] == 10
|
|
22
|
+
assert "mode" not in params
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@pytest.mark.parametrize("command", ["search", "light-search"])
|
|
26
|
+
def test_targeting_options_are_forwarded(monkeypatch, command):
|
|
27
|
+
call = Mock(return_value={"organic_results": []})
|
|
28
|
+
monkeypatch.setattr(google, "api_get", call)
|
|
29
|
+
monkeypatch.setattr(google, "render", Mock())
|
|
30
|
+
result = CliRunner().invoke(
|
|
31
|
+
google.app,
|
|
32
|
+
[
|
|
33
|
+
command,
|
|
34
|
+
"vinted api",
|
|
35
|
+
"--location",
|
|
36
|
+
"New York, USA",
|
|
37
|
+
"--no-cache",
|
|
38
|
+
"--as-sitesearch",
|
|
39
|
+
"github.com",
|
|
40
|
+
"--color-scheme",
|
|
41
|
+
"dark",
|
|
42
|
+
],
|
|
43
|
+
)
|
|
44
|
+
assert result.exit_code == 0, result.output
|
|
45
|
+
params = call.call_args.args[1]
|
|
46
|
+
assert params["location"] == "New York, USA"
|
|
47
|
+
assert params["no_cache"] is True
|
|
48
|
+
assert params["as_sitesearch"] == "github.com"
|
|
49
|
+
assert params["color_scheme"] == "dark"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_raw_html_format_does_not_enter_json_renderer(monkeypatch):
|
|
53
|
+
call = Mock(return_value=b"<html>results</html>")
|
|
54
|
+
monkeypatch.setattr(google, "api_get_raw", call)
|
|
55
|
+
render = Mock(side_effect=AssertionError("HTML must not enter JSON renderer"))
|
|
56
|
+
monkeypatch.setattr(google, "render", render)
|
|
57
|
+
result = CliRunner().invoke(
|
|
58
|
+
google.app, ["search", "cats", "--tbm", "isch", "--response-format", "html"]
|
|
59
|
+
)
|
|
60
|
+
assert result.exit_code == 0, result.output
|
|
61
|
+
assert result.output.strip() == "<html>results</html>"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from unittest.mock import Mock
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
CliRunner = pytest.importorskip("typer.testing").CliRunner
|
|
6
|
-
google = pytest.importorskip(
|
|
7
|
-
"scrapebadger_cli.commands.google", reason="CLI is tested with its own installed package"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_light_search_uses_dedicated_route(monkeypatch):
|
|
12
|
-
call = Mock(return_value={"organic_results": []})
|
|
13
|
-
monkeypatch.setattr(google, "api_get", call)
|
|
14
|
-
monkeypatch.setattr(google, "render", Mock())
|
|
15
|
-
result = CliRunner().invoke(
|
|
16
|
-
google.app, ["light-search", "vinted api", "--gl", "us", "--start", "10"]
|
|
17
|
-
)
|
|
18
|
-
assert result.exit_code == 0, result.output
|
|
19
|
-
path, params = call.call_args.args
|
|
20
|
-
assert path == "/v1/google/light/search"
|
|
21
|
-
assert params["q"] == "vinted api" and params["start"] == 10
|
|
22
|
-
assert "mode" not in params
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/aliexpress.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/apartments.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/app_store.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/autoscout24.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/bestbuy.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/booking.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/chatgpt.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/copilot.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/duckduckgo.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/facebook.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/google_play.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/gumtree.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/idealista.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/immobiliare.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/instagram.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/leboncoin.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/linkedin.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/loopnet.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/onboarding.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/perplexity.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/realtor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/twitter.py
RENAMED
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/wallapop.py
RENAMED
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/walmart.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scrapebadger_cli-0.29.0 → scrapebadger_cli-0.30.0}/src/scrapebadger_cli/commands/youtube.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|