python - how to make an xml http post request from the information provided by the google chrome inspector
问题描述
This question is no duplicate, as adding user-agent to a header isn't fixing anything.
I've been trying to get the response from this URL. It's an XML feed, not an HTML file. It's a live feed updated every second from cashpoint.com's live soccer page. I can just fine get the HTML page from the last-mentioned page, but from the first mentioned URL I can't retrieve the XML data. I can inspect it with google chrome inspector and see the response just fine. But it returns b''. Tried both get and post.
EDIT: Tried to add some more headers but it still doesn't work.
Shouldn't it be possible it retrieve this information if the inspector can see it?
Below is my code and some pictures (if you are too busy to check the links).
import requests
class GetFeed():
def __init__(self):
pass
def live_odds(self):
live_index_page = 'https://www.cashpoint.dk/en/live/index.html'
live_oddsupdate = 'https://www.cashpoint.dk/index.php?r=games/oddsupdate'
r = requests.get(live_oddsupdate)
print(r.text)
feed = GetFeed()
feed.live_odds()
解决方案
好吧,首先,在 Chrome 控制台中,您可以看到它是一个 POST 请求,并且您似乎正在 Python 代码中执行一个 GET 请求。
推荐阅读
- h.264 - 通过 live555 流式传输视频时,将编码器分辨率更改 1 或 2 个像素,解码器在刷新之前不会更改分辨率
- c - 从输入文件中读取输入,不断进入无限循环
- devise - AWS 弹性负载均衡器不适用于 rails devise gem。获取无效的真实性令牌错误
- wolfram-mathematica - 如何在自定义域上使用 Resolve
- python - Amazon EC2 微型实例不响应“which python”命令
- javascript - 如何将搜索栏添加到下拉列表?
- semaphore - semop 失败的无效参数 aix 7.1
- python - 递归如何在此代码段中工作?
- angular - 在 vue.js 中使用 i18n 库和直接从 JSON 中使用 loacle 之间的区别
- c# - 以下示例代码中 AttemptController 中的静态字段是什么意思?