Python Forum
python requests library .JSON() error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python requests library .JSON() error
#1
Can someone explain this? I'm trying to use python requests library, its attributes and methods. while using .JSON()
method I get this error. How should I fix it and why this error? thanks in advance.


import requests
url="https://www.google.com/"
response=requests.get(url).text
print(response.json())
=======================


---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)

----> 7 print(response.json())

AttributeError: 'str' object has no attribute 'json'
Larz60+ write Dec-19-2022, 07:25 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post.
Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed this time, please use BBCode on future posts.
Reply


Messages In This Thread
python requests library .JSON() error - by mHosseinDS86 - Dec-19-2022, 07:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  json loads throwing error mpsameer 8 756 Jan-23-2024, 07:04 AM
Last Post: deanhystad
  Error in blend_modes library talgreen 6 1,036 Jul-01-2023, 05:32 PM
Last Post: talgreen
  json decoding error deneme2 10 3,811 Mar-22-2023, 10:44 PM
Last Post: deanhystad
  Read nested data from JSON - Getting an error marlonbown 5 1,423 Nov-23-2022, 03:51 PM
Last Post: snippsat
  Python Split json into separate json based on node value CzarR 1 5,699 Jul-08-2022, 07:55 PM
Last Post: Larz60+
Question I am struggling with basic json library + sql alchemy w/ mariadb-connector json ->sql BrandonKastning 0 1,537 Mar-04-2022, 09:26 PM
Last Post: BrandonKastning
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,730 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  Python requests oauth2 access token herobpv 6 4,011 Sep-27-2021, 06:54 PM
Last Post: herobpv
  Error about parser library and tree builder Led_Zeppelin 8 11,630 Jun-11-2021, 08:53 PM
Last Post: snippsat
  JSON Decode error when using API to create dataframe Rubstiano7 4 2,995 Jan-11-2021, 07:52 PM
Last Post: buran

Forum Jump:

User Panel Messages

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