Created
April 15, 2024 18:20
-
-
Save AIAnytime/2cd9b3b0861d6be22e87023da6b12950 to your computer and use it in GitHub Desktop.
Jina Reader API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# Base endpoint | |
base_url = "https://r.jina.ai/" | |
# Input URL to be appended | |
input_url = "https://www.stateof.ai/" | |
# Full URL with the input URL appended after a plus (+) sign | |
full_url = base_url + input_url | |
# Headers to include in the request | |
headers = { | |
"Accept": "text/event-stream" | |
} | |
# Make the request with streaming enabled | |
response = requests.get(full_url, headers=headers, stream=True) | |
# Handle the streaming response | |
try: | |
for line in response.iter_lines(): | |
if line: | |
decoded_line = line.decode('utf-8') | |
print(decoded_line) | |
finally: | |
response.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment