You already know it’s ajax, how can you use page source? You can use the "Inspect" function of Chrome browser.
Check to see what you are currently seeing in your browser! ! !
------------------------One more thing---------------------- -- Looking at your needs, you probably want to write a program to post replies in the post bar. I think you don’t need to use selenium.
This is the content captured by the packet capture in chrome when I submitted it, which is the content you submitted in the post. Every item here can be obtained in the "Check" on the current page. Then you can use python to simulate browser submission.
import requests
data = {'kw':'行尸走肉','fid':'815816'} # 自行补充,
url = 'http://tieba.baidu.com/f/commit/post/add' # 在 headers 里有
cookies = 'your_cookies' #把抓包的Headers 里的 cookie 复制整理到这里
#为了防止百度禁止机器人,把 请求里的header 里的 user_agent 改一下。
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.8 Safari/537.36'}
result = requests.post(url,data = data,cookies = cookies,headers = headers)
print(result.status_code) # 返回状态
You already know it’s ajax, how can you use page source? You can use the "Inspect" function of Chrome browser.
Check to see what you are currently seeing in your browser! ! !
------------------------One more thing---------------------- --
Looking at your needs, you probably want to write a program to post replies in the post bar. I think you don’t need to use selenium.
This is the content captured by the packet capture in chrome when I submitted it, which is the content you submitted in the post.
Every item here can be obtained in the "Check" on the current page.
Then you can use python to simulate browser submission.