python 抢票代码 猫眼演出_python爬取猫眼票房的数据,遇到美团登录验证怎么办...

import requests

from fake_useragent import UserAgent

import base64

from lxml import etree

from requests import RequestException

# fake_useragent使用

ua = UserAgent()

def download_page(url):

headers = {

'User-Agent': ua.random,

'Sec - Fetch - Mode': 'no-cors',

'Referer': 'https://piaofang.maoyan.com/?ver=normal'

}

try:

response = requests.get(url=url, headers=headers)

if response.status_code == 200:

return response.content

else:

print(response.status_code)

return None

except RequestException:

print(RequestException.args)

return None

def get_contents(html):

print(html)

def main():

url = 'https://piaofang.maoyan.com/?ver=normal'

html = download_page(url)

get_contents(html)

if __name__ == '__main__':

main()

使用requests.get(url=url, headers=headers)爬取到的网页是美团登录验证的网页,请问怎样才能继续爬取数据

接触爬虫时间不久,所以很多知识不足,请各位大佬指教,提供具体思路就好

谢谢大家,祝大家生活开心