Why urllib.urlopen.read() does not correspond to source code?

前端 未结 5 644
说谎
说谎 2021-01-11 14:02

I\'m trying to fetch the following webpage:

import urllib
urllib.urlopen(\"http://www.gallimard-jeunesse.fr/searchjeunesse/advanced/(order)/author?catalog[0]         


        
5条回答
  •  抹茶落季
    2021-01-11 14:38

    Also, some websites have a so called browser switch which might lead to different source being shown when using different browsers (e.g. show a light version for mobile browsers).

    Have a look at http://www.diveintopython.net/http_web_services/user_agent.html on how to change the User-Agent to something like "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1" (which is actually my User-Agent).

提交回复
热议问题