pang2016 pang2016 - 2 months ago 13
Python Question

requests.session post error 'dict' object has no attribute 'read'

this is my first useage of I analog mobile browser to crawl a website.

this is the headers:
enter image description here

the codes´╝Ü

import requests
from bs4 import BeautifulSoup
import json

'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36'}

print soup

the error:

'dict' object has no attribute 'read'


You want to convert your data dict to a string, then send it using the data= parameter of

soup =, headers=headers, data=json.dumps(data))

Or, if you are using requests version 2.4.2 or newer, you can pass your dict directly using the json= parameter:

soup =, headers=headers, json=data)

Check your requests version with requests.__version__.