Python requests isn't giving me the same HTML as my browser is

前端 未结 6 1109
失恋的感觉
失恋的感觉 2021-01-31 18:56

I am grabbing a Wikia page using Python requests. There\'s a problem, though: the requests request isn\'t giving me the same HTML as my browser is with the very

6条回答
  •  野性不改
    2021-01-31 19:36

    A lot of the differences I see are showing me that the content is still there, it's just rendered in a different order, sometimes with different spacing.

    You could be receiving different content based on multiple different things:

    • Your headers
    • Your user agent
    • The time!
    • The order which the web application decides to render elements on the page, subject to random attribute order as the element may be pulled from an unsorted data source.

    If you could include all of your headers at the top of that Diff, then we may be able to make more sense of it.

    I suspect that the application chose not to render certain images as they aren't optimized for what it thinks is some kind of robot/mobile device (Python Requests)

    On a closer look at the diff, it appears that everything was loaded in both requests, just with a different formatting.

提交回复
热议问题