首页 > 代码库 > phantomjs配置
phantomjs配置
# -*- coding: utf-8 -*- from lxml import html from time import sleep import requests from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium import webdriver url = ‘http://www.tianyancha.com/company/638562997‘ ‘‘‘ for i in range(0, 100000): data = http://www.mamicode.com/requests.get(url)>‘‘‘ dcap = dict(DesiredCapabilities.PHANTOMJS) dcap = { "phantomjs.page.settings.userAgent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36", "phantomjs.page.settings.loadImages": False, "phantomjs.page.settings.resourceTimeout": 5000 } proxy = [ ‘--proxy=120.27.142.209:82‘, ‘--proxy-type=http‘, ‘--ignore-ssl-errors=true‘, ‘--ssl-protocol=tlsv1‘ ] for i in range(0, 50): driver = webdriver.PhantomJS(desired_capabilities=dcap,service_args=proxy) #driver = webdriver.Chrome() driver.get(url) #wait = WebDriverWait(driver, 10) #a = wait.until(EC.presence_of_element_located(By.CSS_SELECTOR, ‘div.datatable‘)) sleep(5) open(‘logs/2.html‘, ‘w‘).write(driver.page_source.encode(‘utf8‘)) print i, driver.title
phantomjs配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。