当前位置:   article > 正文

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)爬取到的网页是美团登录验证的网页,请问怎样才能继续爬取数据

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/631949
推荐阅读
相关标签
  

闽ICP备14008679号