[IPython-User] Peculiar problem with requests module

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[IPython-User] Peculiar problem with requests module

Tony Cappellini-2

On OSX 10.9.5, Python 2.7.8 (32 Bit), iPython 2.2.0

when I execute these lines in the iPython console (cmd prompt)
they execute normally

import requests


When I execute the requests.get() in the notebook, it throws a huge exception.
This makes no sense to me. How can it work in the console, but not in the notebook?

Here is the exception traceback


Would someone explain what happened, and if there is a way to fix it?


Thanks


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Peculiar problem with requests module

Matthias Bussonnier
Hi, 

Here is what I did:

Try in console -> raises.

visit the page with chrome

Try in console -> works.

Try in notebook -> works.

My best guess is the server try to detect if you are trying to scrap it with a bot or actually access to it via browser and 
ban/whitelist your IP (or something alike) 

Try changing the User agent of requests ?

Otherwise IPython-User is at its end of life, we suggest to send question to ipython-dev.

Cheers, 
-- 
M

Le 6 déc. 2014 à 06:37, Tony Cappellini <[hidden email]> a écrit :


On OSX 10.9.5, Python 2.7.8 (32 Bit), iPython 2.2.0

when I execute these lines in the iPython console (cmd prompt)
they execute normally

import requests


When I execute the requests.get() in the notebook, it throws a huge exception.
This makes no sense to me. How can it work in the console, but not in the notebook?

Here is the exception traceback


Would someone explain what happened, and if there is a way to fix it?


Thanks

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Peculiar problem with requests module

Tony Cappellini-2
Message: 2
Date: Sat, 6 Dec 2014 11:57:57 +0100
From: Matthias Bussonnier <[hidden email]>
Subject: Re: [IPython-User] Peculiar problem with requests module
To: "Discussions about using IPython. http://ipython.org"
        <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"


>>Here is what I did:

>>Try in console -> raises.

>>visit the page with chrome

>>Try in console -> works.

>>Try in notebook -> works.

>>Try changing the User agent of requests ?
I don't have much experience with web technologies, not sure what you mean

I will sub to the other list, I keep forgetting to do that

Thanks


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Peculiar problem with requests module

Matthias Bussonnier

Le 7 déc. 2014 à 03:47, Tony Cappellini <[hidden email]> a écrit :


>>Try changing the User agent of requests ?
I don't have much experience with web technologies, not sure what you mean

When you browse the internet, your browser keep saint "Hey I'm chome on OSX", or "Hey I'm Firefox on Linux"

You can ask requests to behave like that:


-- 
M


I will sub to the other list, I keep forgetting to do that

Thanks



_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user