Python Forum
Please help me condense this requests snippet, and answer a basic question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help me condense this requests snippet, and answer a basic question
#2
The returned by get() method object is a class with methods and attributes.

This is why you have to use .text or .content attribute to get the source of the page.

One line:

page = requests.get('http://python-forum.io').content
The .content is the response in bytes while the .text is in Unicode. The other methods and attributes you see when you dir() the response object have quite descriptive names so you get the picture.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
RE: Please help me condense this requests snippet, and answer a basic question - by wavic - Jan-28-2018, 08:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  POST requests - different requests return the same response Default_001 3 2,059 Mar-10-2022, 11:26 PM
Last Post: Default_001

Forum Jump:

User Panel Messages

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