![]() |
Requests in Python for Windows - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Requests in Python for Windows (/thread-897.html) |
Requests in Python for Windows - perthpython - Nov-13-2016 Hi. I'm very new to Python (like 24 hours new). I have setup Python on a Windows machine. I used Python 3.5.2 Have successfully written a small script to fire up a browser and go to a web page with no problem. But now I want to interact with the webpage and am reading Requests is a good way to go. Now to my problem - it seems that Requests needs to be installed and to do that I need PIP. Everything I read suggests PIP is probably already installed as part of Python 3.5.2 but I can't find the "scripts" folder to even confirm if I have PIP and start using it. Maybe its a hidden folder or I'm looking in the wrong place. Any help from someone with experience in Python on windows would be very much appreciated. Thanks in advance. RE: Requests in Python for Windows - snippsat - Nov-13-2016 (Nov-13-2016, 03:10 AM)perthpython Wrote: Everything I read suggests PIP is probably already installed as part of Python 3.5.2 but I can't find the "scripts" folderFollow this. So make sure that "Add Python 3.5 to PATH" and "pip" is marked under installation. And chose a better path like eg C:\Python35. Restart. Now you check that "python" and "pip" command work from anywhere in cmd. pip -V to check version. C:\>pip -V pip 9.0.0 from c:\python34\lib\site-packages (python 3.4) C:\>So this should be 3.5 placement for you. You can upgrade pip,it's okay to do it from Scripts folder("pip.exe" is placed here). Eg. C:\>cd python34\scripts C:\Python34\Scripts>pip install --upgrade pipNow should version be 9.0.1. Now should pip install requests work from anywhere in cmd. RE: Requests in Python for Windows - Larz60+ - Nov-13-2016 In 3.5.2, you don't need to install requests, it's already there in urllib. Now named request Use it this way: import urllib.request as ur url = 'www.google.com' # Your url here rdata = ur.urlopen(url).read().decode('utf8') RE: Requests in Python for Windows - snippsat - Nov-13-2016 No,he mean Requests there is and extra s ![]() RE: Requests in Python for Windows - Larz60+ - Nov-13-2016 Oh, OK is that also for fetching web pages? Checked it out, I do so little (avoid it actually) web programming, I never looked at it until now! RE: Requests in Python for Windows - snippsat - Nov-13-2016 Yes and a much better choice than urllib.request. You don't have to guess on encoding,you get the right encoding As just one example why is better. import requests url = 'http://google.com' rdata = requests.get(url) print(rdata.encoding) # ISO-8859-1 print(rdata.text) # Source codeIt's a popular kid ![]() Quote:Requests is one of the most downloaded Python packages of all time, RE: Requests in Python for Windows - perthpython - Nov-13-2016 Thanks to you both. Very much appreciate your time. Snippsat you are a champion. |