switches = ['--proxy=69.106.88.7:60199', '--proxy-auth=username:password123']
browser = Watir::Browser.new :phantomjs, :args => switches
require 'watir'
def download(url)
page = Watir::Browser.new(:phantomjs,
:args =>['--proxy=124.152.252.194:7895','--load-images=no']
)
page.goto(url)
return page
end
html = download('https://www.baidu.com')##当然不是去爬百度
puts html.body
2017-08-15 10:57:39 WARN Selenium [DEPRECATION] :args is deprecated. Use driver_opts: {args: ["--proxy=124.152.252.194:7895", "--load-images=no"]} instead.
有没有大佬,给说下改怎么办。。
require 'watir'
def download(url)
page = Watir::Browser.new(:phantomjs,
driver_opts: {args: ['--proxy=112.117.119.17:6799','--ignore-ssl-errors=yes']})
begin
page.goto(url)
rescue Exception => e
puts "出现异常#{e.message}"
end
# page.close()
return page
end
html = download('https://www.boip.net/api/myip')
puts html.html