【发布时间】:2023-02-06 23:00:24
【问题描述】:
我正在尝试使用 python 的请求模块来抓取在网站上生成图表的数据。这是有问题的图表:
我的代码目前看起来像这样:
# load modules
import os
import json
import requests as r
# url to send the call to
postURL = "<insert website>"
# utiliz get to pull cookie data
cookie_intel = r.get(postURL, verify = False)
# get cookies
search_cookies = cookie_intel.cookies
#### Request Information ####
# API request data
post_data = <insert request data>
# header information
headers = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"}
# results
results_post = r.post(postURL, data = post_data, cookies = search_cookies, headers = headers, verify = False)
# result
print(results_post.json())
作为一个快速总结,我首先加载站点然后检查它,从那里我在网络选项卡中确定请求的 url,然后在有效负载选项卡中检查所需的请求数据。然后我从请求标头选项卡中获取了用户代理。
请求本身有效,但是它始终为空。我试过改变各种输入但没有成功。我将非常感谢任何有助于我解决此问题的提示。先感谢您!
【问题讨论】:
标签: python web-scraping python-requests