Python Request modülü hatası

Rufiq Cavadov

Kilopat
Katılım
12 Eylül 2013
Mesajlar
3.630
Makaleler
3
Çözümler
10
Yer
Azərbaycan
Daha fazla  
Cinsiyet
Erkek
Merhaba. Python Request modülü ile cookie bilgilerini elde edip json formatı olarak çıktısını almak istiyorum ama Run yaptığım zaman şu şekilde hata almaktayım.

Python:
# import requests module
import requests

# Making a get request
response = requests.get('https://www.technopat.net/sosyal')

# print response
print(response)

# print json content
print(response.json())

1661470883306.png


Kod:
C:\Users\User\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/User/PycharmProjects/pythonProject/main.py
Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\pythonProject\venv\lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\pythonProject\main.py", line 11, in <module>
    print(response.json())
  File "C:\Users\User\PycharmProjects\pythonProject\venv\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
<Response [403]>

Process finished with exit code 1
 
User agent kullanmayı deneyin veya JSON kütüphanesini import etmeyi deneyin.

Böyle olması gerekiyor hocam.

Kod:
import requests

# Making a get request.
url = 'https://www.technopat.net/sosyal'

r = requests.get(url)

data = r.content

print(data)
 
Son düzenleme:

Geri
Yukarı