Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu 下无法运行 #40

Closed
winsonhet opened this issue May 24, 2021 · 12 comments
Closed

ubuntu 下无法运行 #40

winsonhet opened this issue May 24, 2021 · 12 comments

Comments

@winsonhet
Copy link

按照攻略执行到
python3 main.py后产生报错
Traceback (most recent call last):
File "/root/jd/ht/main.py", line 1, in
import ctypes
File "/usr/local/python3/lib/python3.9/ctypes/init.py", line 8, in
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

已经按照百度安装了libffi-devel
python3 版本--Python 3.9.4
请问大神有解决的方法吗

@AntonVanke
Copy link
Owner

AntonVanke commented May 24, 2021

你用的python是否为ubuntu 自带的?
我在deepin下测试并没有这个报错。


不过ctypes是无关紧要的,我已经将一些函数去掉了,应该可以运行。修改后的文件已附上,替换原有的main.py即可
main.py

@winsonhet
Copy link
Author

谢谢您的帮忙,已经更换了main.py,产生了新的报错,这个python3是系统自带的,升级到了3.9.4

日志已生成,查看./logs/ Some log data is being generated: ./log/ ...正在关闭,不要退出
Traceback (most recent call last):
File "/root/jd/ht/main.py", line 72, in get_browser
return webdriver.Chrome(executable_path=get_file_path("drivers/chromedriver"), desired_capabilities={},
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 76, in init
RemoteWebDriver.init(
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in init
self.start_session(capabilities, browser_profile)
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/jd/ht/main.py", line 374, in
main()
File "/root/jd/ht/main.py", line 324, in main
add_cookie()
File "/root/jd/ht/main.py", line 85, in add_cookie
browser = get_browser(False)
File "/root/jd/ht/main.py", line 77, in get_browser
raise WebDriverException
selenium.common.exceptions.WebDriverException: Message: None

@winsonhet
Copy link
Author

之前的版本是可以运行的,这是运行在vps上,没有图形界面,只有文字终端,我想是不是这个原因,无法在第一步跳出浏览器?

@AntonVanke
Copy link
Owner

之前的版本是可以运行的,这是运行在vps上,没有图形界面,只有文字终端,我想是不是这个原因,无法在第一步跳出浏览器?

我刚刚也在想你是否用的是无图形界面的


如果你用的是无图形界面的,你需要先在本地配置完config.json上传上去,防止远程启动浏览器登录

@AntonVanke
Copy link
Owner

如果你的服务器核心/带宽比较少的话,thread建议设置为4以下

@winsonhet
Copy link
Author

还是不行,已经把config放进去

[root@jindou-xianggang ht]# python3 main.py
验证账号1中,中途退出可能会误认为账号失效而删除
日志已生成,查看./logs/ Some log data is being generated: ./log/ ...正在关闭,不要退出
Traceback (most recent call last):
File "/root/jd/ht/main.py", line 374, in
main()
File "/root/jd/ht/main.py", line 326, in main
check_user()
File "/root/jd/ht/main.py", line 300, in check_user
_browser.add_cookie(cookie)
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 894, in add_cookie
self.execute(Command.ADD_COOKIE, {'cookie': cookie_dict})
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/python3/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidCookieDomainException: Message: invalid cookie domain: Cookie 'domain' mismatch
(Session info: headless chrome=90.0.4430.93)

[root@jindou-xianggang ht]#

@AntonVanke
Copy link
Owner

你的服务器是否不在中国大陆?


在境外登录京东会自动跳转到对应的境外京东页面

使用这个Main.py可能会解决问题

@winsonhet
Copy link
Author

谢谢AotonVanke大神的帮助,虽然服务网在香港,确实是这个问题
咱们可以实现静默运行吗,每次运行的时候即使把config文件导入进入后运行,还是依然需要选择,终端需要一直连接上去
以前的版本我都是用nohup命令丢在后台自己跑

@AntonVanke
Copy link
Owner

谢谢AotonVanke大神的帮助,虽然服务网在香港,确实是这个问题
咱们可以实现静默运行吗,每次运行的时候即使把config文件导入进入后运行,还是依然需要选择,终端需要一直连接上去
以前的版本我都是用nohup命令丢在后台自己跑

我已经在尝试将selenium转向更简单的requests了,虽然直接的访问可能会被黑号
后续会有直接运行的,且不需要浏览器驱动了

@HANSCOM123
Copy link

完整版shopid可以提供一份吗~AotonVanke大神

@winsonhet
Copy link
Author

期待您的更新

@AntonVanke
Copy link
Owner

AntonVanke commented May 26, 2021

完整版shopid可以提供一份吗~AotonVanke大神

是50万的那个吗,你可以看看提交记录#4de8dbc7e0bc748feddcb07574e77daaeca91454前几版的就是的,后来我重新遍历了一遍才这么少了,主要是好多店铺没有店铺会员

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants