Skip to content

Instantly share code, notes, and snippets.

@yacineali74
Forked from AIAnytime/reader.py
Created April 16, 2024 01:32
Show Gist options
  • Save yacineali74/e52ab7322586930c4ae6ad793c835dd2 to your computer and use it in GitHub Desktop.
Save yacineali74/e52ab7322586930c4ae6ad793c835dd2 to your computer and use it in GitHub Desktop.

Revisions

  1. @AIAnytime AIAnytime created this gist Apr 15, 2024.
    27 changes: 27 additions & 0 deletions reader.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    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()