【python笔记】腾讯动漫爬取(更新)

 具体参照我之前写的一个笔记:https://blog.csdn.net/qq_40937976/article/details/79856622

目前腾讯动漫阅读界面的滑动需要切换到指定窗口,即漫画照片页所在div

'var q=document.getElementById("mainView").scrollTop ='+str(i*3000)

才可以滑动

import requests
import urllib.request
import re
import selenium.webdriver
import random
import time
from PIL import Image
from io import BytesIO
import os
from lxml import etree
headers = ("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)"
                        " Chrome/65.0.3325.146 Safari/537.36")
opener = urllib.request.build_opener()
opener.addheaders = [headers]
urllib.request.install_opener(opener)
driver = selenium.webdriver.Chrome()
def get_ac(url):
    driver.implicitly_wait(30)
    driver.get(url)
    time.sleep(1)
    n=20
    for i in range(1,n+1):
        # fr=driver.find_element_by_xpath('//*[@id="checkVipFrame"]')
        # driver.switch_to.frame(fr)
        time.sleep(random.randint(0,3))
        s ='var q=document.getElementById("mainView").scrollTop ='+str(i*3000)
        driver.execute_script(s)
    content=driver.page_source
    return content
lpat= '

 

你可能感兴趣的:(【python笔记】腾讯动漫爬取(更新))