21 lines
675 B
Python
21 lines
675 B
Python
import requests
|
|
|
|
H = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/128",
|
|
"Accept": "text/event-stream"}
|
|
q = "DEEPSEEK_API_KEY"
|
|
r = requests.get("https://sourcegraph.com/.api/search/stream",
|
|
params={"q": f'{q} count:20', "v": "V3", "t": "literal", "display": "20"},
|
|
headers=H, timeout=30, stream=True)
|
|
print("status:", r.status_code, r.headers.get("content-type", "")[:40])
|
|
n = 0
|
|
chunk = []
|
|
for line in r.iter_lines(decode_unicode=True):
|
|
if line is None:
|
|
continue
|
|
chunk.append(line)
|
|
n += 1
|
|
if n > 40:
|
|
break
|
|
text = "\n".join(chunk)
|
|
print("lines:", n)
|
|
print(text[:800]) |