简体   繁体   English

在python的PhantomJs中使用proxy(private)

[英]Using proxy(private) in PhantomJs with python

I am using a private poxy IP with PhatomJS and Python, My code below 我正在使用带有PhatomJS和Python的私有poxy IP,下面的代码

phantomjs_path = r"phantomjs.exe"
service_args = [
    '--proxy=MY Private IP',
    '--proxy-type=socks5',
    '--proxy-auth=username:password', # I enter real user name and pass here
    ]

browser = webdriver.PhantomJS(executable_path=phantomjs_path,service_args=service_args)
browser.get("Any website") # I use any website unblocked on that I.P
print(browser.page_source)

when I run the bot and I am trying to get the page source 当我运行机器人并试图获取页面源代码时

But the output for any page is this why? 但是任何页面的输出是为什么?

<html><head></head><body></body></html>

There is no error message shown I don't know what I have missed here? 没有显示错误消息,我不知道我在这里错过了什么?

Also tested with sleep function(I thought the page took some time to load) 还测试了睡眠功能(我认为该页面需要花费一些时间来加载)

The port number needs to be added here, 需要在此处添加端口号,

service_args = [
'--proxy=MY Private IP:port',  # See the difference
'--proxy-type=socks5',
'--proxy-auth=username:password', # I enter real user name and pass here
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM