admin管理员组

文章数量:1529451

  • 看代码:
from selenium import webdriver

class Chrome_headless:
    """无头的Chrome浏览器"""

    def __init__(self):

        self.chromeOptions = webdriver.ChromeOptions() # chrome 选项设置对象
        self.chromeOptions.add_argument('headless') # 设置无界面
        self.chromeOptions.add_argument('window-size=1200x600') # 虚拟屏幕大小
        self.wb = webdriver.Chrome(chrome_options=self.chromeOptions) # 创建chrome 浏览器对象

    def get_parse(self, url):
        self.wb.get(url)
        self.wb.set_window_size(1366, 768) # 设置请求之后的虚拟界面大小,以便获取页面的内容。
        html = self.wb.page_source
        print(html)
if __name__ == '__main__':
    chrome = Chrome_headless()
    chrome.get_parse("https://www.baidu/")

本文标签: 界面浏览器chrome