Python Forum
Requests in Python for Windows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Requests in Python for Windows
#1
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.
Reply
#2
(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" folder
Follow 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 pip
Now should version be 9.0.1.

Now should pip install requests work from anywhere in cmd.
Reply
#3
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')
Reply
#4
No,he mean Requests there is and extra Wink
Reply
#5
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!
Reply
#6
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 code
It's a popular kid Cool
Quote:Requests is one of the most downloaded Python packages of all time,
pulling in over 7,000,000 downloads every month. All the cool kids are doing it!
Reply
#7
Thanks to you both. Very much appreciate your time.  Snippsat you are a champion.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python requests library .JSON() error mHosseinDS86 6 3,238 Dec-19-2022, 08:28 PM
Last Post: deanhystad
  Python requests oauth2 access token herobpv 6 3,771 Sep-27-2021, 06:54 PM
Last Post: herobpv
  Python Requests SSL Aussie 0 1,960 Jan-07-2021, 02:09 AM
Last Post: Aussie
  Python Requests Aussie 2 2,690 Dec-23-2020, 03:24 AM
Last Post: Aussie
  Python Requests package: Handling xml response soumyarani 1 2,101 Sep-14-2020, 11:41 AM
Last Post: buran
  Python API and requests deep_logic 9 4,181 Jul-29-2020, 03:47 PM
Last Post: ndc85430
  How to save Python Requests data sent to server? RedLeonard 5 4,798 Jul-05-2020, 10:33 AM
Last Post: RedLeonard
  How to do the same as python -m requests.certs inside script? geekgeek 2 2,233 Feb-27-2020, 07:11 AM
Last Post: buran
  Python requests writes the name of the file instead of contents to web page bluethundr 1 2,123 Jun-05-2019, 09:35 PM
Last Post: Larz60+
  Python requests module doesn not return status_code palo173 5 3,364 May-21-2019, 09:22 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020