zoukankan      html  css  js  c++  java
  • 待处理的电影天堂

    # coding=utf-8

    import requests
    from lxml import etree
    a='https://www.dytt8.net'
    headers={
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36',
    'Referer':'https://www.dytt8.net/html/gndy/dyzz/list_23_3.html'
    }


    def get_detail_urls(url):
    response=requests.get(url,headers=headers)
    text=response.text
    html=etree.HTML(text)
    detail_urls=html.xpath("//table[@class='tbspan']//a/@href")
    detail_urls = map(print(lambda url:a+url,detail_urls))
    return detail_urls()

    def spider(url):
    base_url="https://www.dytt8.net/html/gndy/dyzz/list_23_().html"
    for x in format(1,8):
    url=base_url.format(x)
    detail_urls=get_detail_urls(url)
    for detail_url in detail_urls:
    movie=parse_detail_page(detail_url)

    def parse_detail_page(url):
    movie={}
    response = requests.get(url, headers=headers)
    text = response.text
    html = etree.HTML(text)
    title=html.xpath("//div[@class='title all'//font[@color='#07519a']/text()")[0]
    movie['title']=title
    print(title)

    zoomE=html.xpath("//div[@id='zoom']")[0]
    imgs=zoomE.xpath("//img[@src]")[0]
    covers=imgs[0]
    screenshot=imgs[1]
    movie['covers']=covers
    movie['screenshot']=screenshot
    infos=zoomE.xpath(".//text()")
    print(infos)
    for info in infos:



  • 相关阅读:
    IE浏览器兼容问题
    sublime text3插件和快捷键
    CSS3高级
    盒子模型
    css3动画
    FreeBSD port安装 *** [checksum] Error code 1
    vs 2008设置vs6.0字体
    android 无法读取lua文件问题2
    u盘安装centos6 x8664
    cocos2dx lua 路径问题的一个bug (网络整理)
  • 原文地址:https://www.cnblogs.com/lumc5/p/11216500.html
Copyright © 2011-2022 走看看