Skip to content

Instantly share code, notes, and snippets.

@AIAnytime
Created April 15, 2024 18:20
Show Gist options
  • Save AIAnytime/2cd9b3b0861d6be22e87023da6b12950 to your computer and use it in GitHub Desktop.
Save AIAnytime/2cd9b3b0861d6be22e87023da6b12950 to your computer and use it in GitHub Desktop.
Jina Reader API
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