OCY
OCY

Reputation: 1

Python requests not giving back >>> prompt

I have requests installed already and yes it is up to date. Importing requests, writing down headers and writing down URL is fine. They return the >>> prompt. When I write:

>>> res = requests.get(url, headers=headers)

nothing returns. I don't even get the >>> prompt. everything else i write after this do not respond, does not have the >>> and is only black in colour.

Upvotes: 0

Views: 102

Answers (1)

Will
Will

Reputation: 5470

You need to pass in a timeout, allowing the call to stop after a certain amount of time.

Replace

res = requests.get(url, headers=headers)

with

r = requests.get(
    url,
    headers=headers,
    timeout=5
)

Upvotes: 1

Related Questions