def plantjs_request(url):
desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
# 1. User-Agent
desired_capabilities['phantomjs.page.settings.userAgent'] = UserAgent().random
desired_capabilities['phantomjs.page.settings.loadImages'] = False
# 2. Proxy
# proxy = webdriver.Proxy()
# proxy.proxy_type = ProxyType.MANUAL
# proxy.http_type = random.choice(ips)
# proxy.add_to_capabilities(desired_capabilities)
# 3. 打开配置好的浏览器
driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities)
# 4. 设置页面超时返回
# driver.set_page_load_timeout(20)
# driver.set_script_timeout(20)
driver.get(url)
time.sleep(1)
body = driver.page_source
driver.quit()
return body