首页 > 解决方案 > 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()

enter image description here enter image description here

标签: pythonpython-requests

解决方案


好吧,首先,在 Chrome 控制台中,您可以看到它是一个 POST 请求,并且您似乎正在 Python 代码中执行一个 GET 请求。


推荐阅读